X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 	tests=AWL,BAYES_00,J_CHICKENPOX_45,MISSING_HEADERS,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
Date: Thu, 19 Feb 2009 14:33:08 -0600 (CST)
From: Tim McDaniel <tmcd@panix.com>
cc: cygwin@cygwin.com
Subject: Re: fstream - problem with reading/writing to file
In-Reply-To: <499DAEA9.90309@mff.cuni.cz>
Message-ID: <Pine.NEB.4.64.0902191430250.24046@panix3.panix.com>
References: <499DAEA9.90309@mff.cuni.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

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/

