// read a file into memory #include #include using namespace std; int main () { ifstream is; is.open ("test.txt"); char c, c1, c2, c3; is >> c1; is.tellg(); // Causes bug. Remove and result will be correct is >> c2; is >> c3; // The number of chars skipped in case of buggy behavior depends // on the number of lines in the file. // The bug is only present on files with DOS line endings e.g. // if I convert the file with dos2unix, no problem appears cout << "The first 3 chars are " << c1 << c2 << c3 << endl; return 0; }