The struct "board" is the problem because no error occurs when I put the
struct into comment symbol. Probably because an array inside the struct is
too big in size. (rec[11001][10001])
On Wednesday, March 7, 2012 3:41:26 PM UTC+8, freegyp 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 view this discussion on the web visit
https://groups.google.com/d/msg/google-code/-/AOUzuiPkoykJ.
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.