//program that illustrates the use of getline to input multiple word strings //******************SAMPLE DATA FILE************************ // Wayne * // 1234 * // Wayne Summers * // -234 * //********************************************************** #include#include void main () { char first[10]; int nbr1, nbr2; char fullName[25]; char eo[2]; ifstream infile; infile.open("file.dat"); //********************************************************** // use >> if reading in a number or a string with no spaces * //********************************************************** infile >> first; infile >> nbr1; //*************************************************************** // use getline if reading in a string with spaces; * // be sure to clear out the preceeding cR and newline characters * //*************************************************************** infile.getline(eo,2,'\n'); infile.getline(fullName,25,'\n'); infile >> nbr2; infile.close(); cout << "\nfirst name is " << first; cout << "\nnumber is " << nbr1; cout << "\nfull name is " << fullName; cout << "\nnumber is " << nbr2; }