istream: seekg / tellg, peculiar behaviour
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
I'm having two
istream
-related problems. Please can somebody help... :confused: Problem 1void loadStuffFromStream (istream& stream) { // goes too far!! stream.seekg( length, ios_base::cur ); }
***edited*** This seems to skip to an arbitrary position in the stream, instead of 'current position' +
length
bytes. Why does it do this? Problem 2char ch; int pos; ... pos = stream.tellg(); // now pos=0 stream.get (ch); pos = stream.tellg(); // now pos=3585 ??? stream.get (ch); pos = stream.tellg(); // now pos=3586 stream.get (ch); pos = stream.tellg(); // now pos=3587 stream.get (ch); // etc...
Not so much a 'problem' as a matter of curiosity. Why is there a sudden leap in the read-position reported by
tellg
the first time I read from the stream? (N.B. It is reading the correct characters intoch
!)