This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC 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]

Re: libstdc++/5629: fstream class is unable to create file in a read/write mode


Synopsis: fstream class is unable to create file in a read/write mode

State-Changed-From-To: feedback->closed
State-Changed-By: paolo
State-Changed-When: Thu Feb  7 15:35:50 2002
State-Changed-Why:
    Not a bug. v3's iostreams are much more conforming to the
    standard and according to the latter in|out corresponds
    to C's "r+" (i.e., file *must* exist). Use open mode out
    to create the file. That is:
    #include <fstream>
    #include <unistd.h>
    using namespace std;
    
    int main()
    {
        char text[256];
        fstream* fs = new fstream("test.tmp",ios::out);
        strcpy(text,"This is a test\n");
        fs->write(text,strlen(text));
        fs->close();
        delete fs;
    }
    
    P.S. For further details see, f.i., Josuttis, p 631-634.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5629


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