delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
To: | cygwin AT cygwin DOT com |
From: | "Alex Vinokur" <alexvn AT users DOT sourceforge DOT net> |
Subject: | Behavior of ifstream::read() in g++ |
Date: | Sun, 15 Oct 2006 06:10:17 +0200 |
Lines: | 81 |
Message-ID: | <egscaa$5sd$1@sea.gmane.org> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
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 |
This program has different behavior in * g++ 3.4.4 (Cygwin) * gpp 4.0.1 *Djgpp) * Microsoft C++ 13.00.9466 ------- foo.cpp ------ #include <iostream> #include <iomanip> #include <fstream> using namespace std; #define BUFFER_SIZE 1500 #define INPUT_FILE_NAME "in.txt" void foo () { char cbuffer[BUFFER_SIZE]; ifstream fs (INPUT_FILE_NAME); fs.clear(); fs.seekg (0, ios::beg); while (!fs.eof()) { fs.read (cbuffer, sizeof(cbuffer)); cout << "rdstate() = 0x" << hex << fs.rdstate() << dec << "; gcount() = " << fs.gcount() << endl; } cout << "rdstate() = 0x" << hex << fs.rdstate() << dec << endl; } int main () { foo (); return 0; } ---------------------- Test input file can be seen at http://groups.google.com/group/test-av/msg/0c4d3da487594ab7 Output for g++ (Cygwin) -------------------- rdstate() = 0x6; gcount() = 1499 rdstate() = 0x6 ------------------- It seems that behavior of g++ is wrong here. Output for gpp (Djgpp) ------------------- rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x6; gcount() = 1071 rdstate() = 0x6 ------------------- Output for Microsoft C++ ------------------- rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x3; gcount() = 1071 rdstate() = 0x3 ------------------- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn -- 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 |