I have an assignment that I`m working on that requires me to read characters from a file and input them into an array. The only problem that I`m having thus far is being able to skip over the '\n' and ' ' (space) characters. Can anyone please help me with this? The function in my program that is giving me trouble is as follows:
Code:void insert(char A[]) { char nb; int r=0; infile.open("lab05.dat", ios::in); if(!infile) { cerr << "Can not find the file\n"; exit(1); } while(!infile.eof()) { infile.get(nb); while(nb=='\n') { infile.ignore(); infile.get(nb); A[r]=nb; cout << A[r]; r++; } if(nb==' ') { infile.get(nb); A[r]=nb; cout << A[r]; r++; } else { A[r]=nb; cout << A[r]; r++; } } }