LiquidEyes
Programmer
I'm having two istream-related problems. Please can somebody help...
Problem 1
void loadStuffFromStream (istream& stream)
{
// goes too far!!
stream.seekg( length, ios_base::cur );
}
This always skips (length*2) bytes instead of length. Why does it do this? I thought istream was specialised on chars not w_chars?
Problem 2
char 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 into ch!)
Problem 1
void loadStuffFromStream (istream& stream)
{
// goes too far!!
stream.seekg( length, ios_base::cur );
}
This always skips (length*2) bytes instead of length. Why does it do this? I thought istream was specialised on chars not w_chars?
Problem 2
char 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 into ch!)