fstream - problem with reading/writing to file
Tim McDaniel
tmcd@panix.com
Thu Feb 19 20:33:00 GMT 2009
On Thu, 19 Feb 2009, Pavel Kudrna <Pavel.Kudrna@mff.cuni.cz> wrote:
> I have found problem with read and write to file using fstream. The
> following example opens existing file for read+write, separately
> writes "Hello" and " world!" and in between it tries to read one
> character from the file. The problem is that without call to seekg()
> or tellg() the read fails and without seekp() or tellp() the second
> write of " world!" to the file fails too. The same program works on
> linux with gcc 3.2.2.
I'm pretty sure that at least the C standard for stdio said that,
between a read and a write (and the reverse), it was necessary to do a
seek on the file. But I don't have a citation for that, and I don't
know much about C++ I/O to know what rules exist there. I only
mention this in case it might prompt someone else who knows where to
look.
--
Tim McDaniel, tmcd@panix.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list