I can't use an array of 1'000.000 of ints?

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
Disatoba
New poster
Posts: 6
Joined: Thu Feb 02, 2006 3:32 pm
Location: Bogot

I can't use an array of 1'000.000 of ints?

Post by Disatoba »

I declared an array of 1'000.000 of ints, and my program in C compile perfectly, but when run it, it crashed, why?

can't i use an array with more 1'000.000 of ints or longs?

I use Devcpp to write my programs.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

hmm... :-?

Post by sohel »

Possibly you are declaring the array locally ( ie inside the main() or any other fun() ).

Declaring it as global should solve the problem.

Code: Select all

  int main() {
      int large_array[1000000];
  }
This code will crash.

Code: Select all

  int large_array[1000000];
  int main() {

  }
This one will work.
Disatoba
New poster
Posts: 6
Joined: Thu Feb 02, 2006 3:32 pm
Location: Bogot

Thanks

Post by Disatoba »

It means than can't i declare un array of 1000.000 ints as local variable?
Never?
Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko »

Post Reply

Return to “C”