but the last two characters not always are found. At a certain point fseek no longer finds the two last characters.
Now I've changed function. I changed my code this way:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
ifstream inf("file.txt");
// If we couldn't open the input file stream for reading
if (!inf)
{
// Print an error and exit
cerr << "Uh oh, file.txt could not be opened for reading!" << endl;
exit(1);
}
string strData;
inf.seekg(-2, ios::end); // move 15 bytes before end of file
// Get rest of the line and print it
getline(inf, strData);
and things seem go right.
May be the fseek function is unsafe?
Thanks in advance and goodbye.