User forums > Using Code::Blocks
Too big array size
(1/1)
haxmando:
I found out that when i declare a quite big array, for example int array[1000][100];
The program will crash, still it can handle smaller arrays. Could you say what is causing this?
I'm using Gnu gcc compiler.
seb_seb0:
this is not a Code::Blocks question - your post will probably be locked.
However, here is an answer for you: if you are allocating an array inside a function (inside {}), then memory on the Stack will be allocated (the Stack is a temporary memory allocated at function call, and freed at function exit).
The Stack has a limited capacity (it depends on the OS). So when you are allocating a very big array, you are using more memory than the Stack can handle.
And every Stack error leads to a program crash.
For the same reason, recursive functions are a very bad idea.
I suggest you to find a good book and / or web site for learning the programmation, this one for example:
http://www.cppreference.com/wiki/start
regards,
Sebastien
Navigation
[0] Message Index
Go to full version