🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #1836

Possible bug in GCC/2 iostreams???

#1836
From: Brian Button
Date: Wed, 11 Nov 1992 12:24
42 lines
1631 bytes
I seem to be having a problem reading in the contents of a file using
iostreams. When I use any multi-char read methods, I get the first
byte twice. For example :

{
    ifstream ifs( "test.data" );
    char buf[ 16 ];
    ifs.read( buf, 16 );
}

If the contents of test.data are "abcdefghijklmnop", I'll read
"aabcdefghijklmno".

If I change the reading code to

	ifs.rdbuf( )->sgetn( buf, 16 );

I get the same results.

However, if I change to

    for( i = 0; i < 16; i++ )
    {
        int ch = ifs.rdbuf( )->sgetc( );
    }

everything works fine for me.

Am I doing something wrong here or is this a bug in GCC/2?

thanks,

bab

--
|-----------------------|----------------------------------------------------|
| Brian Button          | email : button@wg2.waii.com                        |
| Design Engineer       |         71023.276@compuserve.com                   |
| Western Geophysical   | voice : (713)964-6221                              |
| 3600 Briarpark        |----------------------------------------------------|
| Houston, Texas  77042 |                  Opinions Be Mine!!                |
|-----------------------|----------------------------------------------------|
Technical Details
Message-ID: <BAB.92Nov11072433@se39.wg2.waii.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!airgun!airgun.wg.waii.com!bab

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!airgun!airgun.wg.waii.com!bab
From: bab@se39.wg2.waii.com (Brian Button)
Newsgroups: comp.os.os2.programmer
Subject: Possible bug in GCC/2 iostreams???
Message-ID: <BAB.92Nov11072433@se39.wg2.waii.com>
Date: 11 Nov 92 12:24:33 GMT
Sender: news@airgun.wg.waii.com
Organization: Western Geophysical Exploration Products
Lines: 42
Nntp-Posting-Host: se39.wg2.waii.com