www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/02/19/16:13:14

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 <gchicares AT sbcglobal DOT net>
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> <Pine DOT NEB DOT 4 DOT 64 DOT 0902191430250 DOT 24046 AT panix3 DOT panix DOT com>
In-Reply-To: <Pine.NEB.4.64.0902191430250.24046@panix3.panix.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <Pavel DOT Kudrna AT mff DOT cuni DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019