#define SIZE 30
// some code
ifstream outFile;
outFile.open("lab.txt"); // opening lab document which has a sentence
char buffer[SIZE]; // buffer for storing the sentence when reading from file
while (!outFile.eof()) // reads lab.txt until eof
{
// two methods for output to screen which print sentence on debugging
// but program doesn't terminate
outFile >> buffer;
cout << buffer << endl;
// outFile.getline(buffer, SIZE);
// cout << buffer << endl;
}
this code is for reading from a sequence file, for example lab.txt
. The problem is that, when i run the sentence in the file, i gets printed but is followed by an infinite loop which keeps on printing spaces, so the program never terminates. I've tried both ways but both result is the same.
Any help would be welcomed?