This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fstream - problem with reading/writing to file


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]