This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with fstream


I posted this to gnu.g++.help today, but I though I might get a quicker 
response here:

Stuart Mentzer wrote on Jan 13 2002
>Hello,

>I built GCC 3.0.3 on an up-to-date Cygwin installation.
>I am having a problem with ofstream output of std::endl
>that doesn't show up with GCC 2.95.3.  I am not sure if
>this is a bug or some lack of a switch somewhere.

>In the example below the output file Line1 gets a UNIX-type
>newline (0D) instead of DOS-type (0D0A) but the last
>line is terminated with a DOS-type newline.  In some
>situations in my real app the endl even causes a previous
>character to be eliminated.  If I use '\n' instead of endl
>I don't have this problem.  It also doesn't show up if I
>redirect cout output to a file.

>So, is this a bug?  If so, other than changing all my endl's
>to '\n' and a flush() can anyone suggest a simple work-
>around?

>Thanks.

>Stuart
I'm seeing the same problem I think. Using fstream, "<< endl" results in
'\r' being written to the file. I was trying to read the file back using
getline() and it only worked at all if I specified '\r' as the delimiter.
I thought I could live with this, but there is another problem: occasionally
a '\r' delimiter is missed, so the getline() call misses a line from the 
file.
Looking at the output of "od -c" on the file, it seems like this problem
happens when the delimiter is on a block boundary.
Is there a fix/work-around available?

Chris


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]