delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT 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 AT panix DOT com> |
cc: | cygwin AT cygwin DOT 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 DOT 90309 AT mff DOT cuni DOT cz> |
MIME-Version: | 1.0 |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 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 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 AT panix DOT 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |