X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_40,J_CHICKENPOX_45 X-Spam-Check-By: sourceware.org Message-ID: <499DCB5C.2090606@sbcglobal.net> Date: Thu, 19 Feb 2009 21:13:00 +0000 From: Greg Chicares User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: fstream - problem with reading/writing to file References: <499DAEA9 DOT 90309 AT mff DOT cuni DOT cz> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 2009-02-19 20:33Z, Tim McDaniel wrote: > On Thu, 19 Feb 2009, Pavel Kudrna 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/