Alas, your code is wrong.
When you got the last word file.eof() is not true! Only the next file>>Word expression changes the file stream state to eof (and does not read anything). After that all operations on the file stream are suppressed until you clear() the stream.
That's right file scan loop:
while (file >> Word) {
...
}
if (file.eof()) {
file.clear();
// Now tellg/seekg work again
} else {
// i/o error, stop processing.
}
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348