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 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: References: <499DAEA9 DOT 90309 AT mff DOT cuni DOT cz> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 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 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/