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
User avatar
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 » Mon Jan 29, 2007 3:56 pm

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.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

hmm... :-?

Post by sohel » Mon Jan 29, 2007 4:50 pm

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.

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

Thanks

Post by Disatoba » Mon Jan 29, 2007 5:19 pm

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 » Mon Jan 29, 2007 8:55 pm


Post Reply

Return to “C”