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]

RE: File Stream Open Problem with g++ 3.3.3 and libstdc++.so.5


Hi Paolo

As per your suggession, I used "ofstream" instead of "ifstream"
in my code, but unfortunately, the result was same before, after
254 successful streams openning, assertion occured, but I am 
supposed to open 1000 streams to the same file "boo".

NOTE: I have one existing file named "boo" in the same directory of a.out.

My Code :
==========================================
#include <assert.h>
#include <fstream>
#include <iostream>
#include <string>

const int MAX_STREAM = 1000;

using namespace std;

int main(int argc, char* argv[])
{
        ofstream in[MAX_STREAM];
        string file("boo");

        for ( int i=0; i != MAX_STREAM; i++ )
        {
                in[i].open(file.c_str());
                cout << "i : " << i << endl;
                assert(in[i]);
        }
        return 0;
}
=========================================

Please let me know your opinion.

With Very Best Regards

Subrata Basak




-----Original Message-----
From: Paolo Carlini [mailto:pcarlini@suse.de]
Sent: Monday, March 29, 2004 5:49 PM
To: Subrata Basak
Cc: 'gcc-libstdc++'
Subject: Re: File Stream Open Problem with g++ 3.3.3 and libstdc++.so.5


Hi,

according to the ISO standard, now closely tracked, the default
open mode of ifstream is "in", the equivalent of C "r", therefore
_file must exist_: indeed, changing your snippet to use ofstream
leads to the expected behavior.

Paolo.

P.S. gcc-help is much more suited for this kind of doubts.


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