#946 ofstream::write places linefeed after carriage return

gcc (462)

It would seem that the implementation of
ofstream::write feeds a line feed following a carriage
return. My suspicion is that operator<< code was used
to implement this method. That is counter to the
standard and can make for problems that are very
difficult to detect. This glitch makes writing binary
files using ofstream impossible.


  • Earnie Boyd

    Earnie Boyd - 2006-05-30
    • labels: 104601 --> gcc
  • Luke Dunstan

    Luke Dunstan - 2006-05-31

    Logged In: YES

    Did you mean to say that it writes a carriage return+line
    feed if you tell it to output a line feed? Did you open
    the file in binary mode? If not this is normal.

  • Nick Apperson

    Nick Apperson - 2006-05-31

    Logged In: YES

    I was under the mistaken impression that write() always
    wrote data as binary, but after further review of the
    standard, I am now unclear on this. I will take your word
    for it. I still haven't found anywhere that unambiguously
    states one way or another about write, but I am sure I will
    find it soon enough. Thanks for the response. Sorry for
    wasting your time.

  • Earnie Boyd

    Earnie Boyd - 2006-05-31

    Logged In: YES

    So, to counteract you can add /mingw/lib/binmode.o to your
    link step to force the binary mode file handles. For more
    information on this google for "binary vs text mode" without
    the quotes and also "binary vs text mode _fmode".

  • Earnie Boyd

    Earnie Boyd - 2006-05-31
    • milestone: --> Known_Feature
    • status: open --> pending-invalid
  • SourceForge Robot

    • status: pending-invalid --> closed-invalid
  • SourceForge Robot

    Logged In: YES

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 30 days (the time period specified by
    the administrator of this Tracker).


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks