On 2009-02-19 20:33Z, Tim McDaniel wrote: > On Thu, 19 Feb 2009, Pavel Kudrna <pavel.kud...@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
I think you mean C99 7.19.5.3/6, which says "output shall not be directly followed by input without an intervening call to the fflush function or to a file positioning function" and vice versa. > 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. The C++ standard refers to the C standard for low-level stuff like this. -- 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/