The program is supposed to read the number of vowels and the number of consonants in an external file (".txt") which it does, but I need to be able to "rewind"/go back to the start of the file, and I found a way to do this but am not sure how to check it?
Because sentence still equals the last line. You moved the pointer (seekg) back to the beginning, but printed out the last line again. You need to read from the file (inf) to prove that you're back at the beginning, not use data already stored in a variable.
do {
getline (inf,sentence);
c += sentence.length();
n++;
}
//sentence contains the last sentence in file (Fallen cold and dead)
inf.clear();
inf.seekg(0, ios::beg);
cout << sentence << endl; //sentence is still containing the last sentence
inf.close();
You should put getline (inf,sentence); after rewind and before cout << sentence << endl;