Re: Grrr... C++ file I/O
On Jun 9, 12:48 am, "osmium" <r124c4u...@comcast.net> wrote:
"SpreadTooThin" writes:
Am I correct the tellg resets the stream to the begining of the file?
No. I forgot to mention, g stands for get and p stand for put; there are
two pointers into the file. seekg(0) and seekp(0) will get you to the
beginning of the file, may be syntax errors, I am writing from memory.
No there aren't. In general, at the [io]stream level, it is
unspecified whether a bi-directional stream maintains two
pointers, or one. The interface is designed to support two,
since some streams (e.g. stringstream) do support two, but
changing the read position (seekg()) on a fstream will also
change the write position.
Be aware, too, that all of the restrictions as to what
positionning is legal on a FILE* also apply to [io]stream. In
practice, on a text stream, you can only seek to the beginning,
or to a place where you've been before, and whose position you
obtained using tell[gp]. (And of course tell[gp] never changes
the position in the file.)
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34