You did not initialize the stream fin

On 08/03/2012 04:59, "freegyp" <[email protected]> wrote:

I have written a program in C++ today but segfault occurred when I ran
the program. DDD told me that the segfault occurred when I was trying
to create the ifstream object at the start of "int main()". The code
is as following(board is a struct created by my own):

typedef multiset<int> mint;
int main()
{
       ifstream fin;
       fin.open("B-small-practice.in");
       ofstream fout("gypBsmall.out");
       int T,N;
       mint ns;
       fin>>T;
       for(int i=0;i<T;i++)
       {
               fin>>N;
               for(int j=0;j<N;j++)
               {
                       int temp;
                       fin>>temp;
                       ns.insert(temp);
               }
               board new1(ns);
               fout<<"Case #"<<i+1<<": "<<new1.findsec()<<endl;
               ns.clear();
       }
       fin.close();
       fout.close();
       return 0;
}


It's not the first time I use ifstream but I have never seen segfault
like this. Can anybody tell me what's wrong with the program?

--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to