Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: haxmando on April 15, 2010, 10:55:16 pm
-
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.
-
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 (http://www.cppreference.com/wiki/start)
regards,
Sebastien