delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/09/01/21:01:19

Date: Thu, 1 Sep 94 19:55:17 EDT
From: dliu AT faraday-gw DOT njit DOT edu (Dong Liu)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: libgpp ofstream bug?
Mailer: VM 5.32 (beta) for GNU Emacs 18.59.5

This little program will not work when compiled by gcc 2.6.0 with libgpp
2.60

---- test program ---
#include <iostream.h>
#include <fstream.h>
main()
{
    ofstream of("test.dat", ios::bin);
    of << "hello\nworld\n\r";
    if (!of)
        cerr << "Error writing to file\n";
}

It will work when compiled by MSVC (replacing ios::bin with
ios::binary).

To make it work with libgpp I need to use a line like this

    ofstream of("test.dat", ios::bin|ios::out);

Is an ofstream object supposed to be for output?

--
Dong Liu  <dliu AT ace DOT njit DOT edu>
Electrical and Computer Engineering Department
New Jersey Institute of Technology, Newark, NJ 07102

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019