The matrix
is a local variable inside your main
function. So it is "allocated" on the machine call stack.
This stack has some limits.
You should make your matrix
a global or static
variable or make it a pointer and heap-allocate (with e.g. calloc
or malloc
) the memory zone. Don't forget that calloc
or malloc
may fail (by returning NULL).
A better reason to heap-allocate such a thing is that the dimensions of the matrix should really be a variable or some input. There are few reasons to wire-in the dimensions in the source code.
Heuristic: don't have a local frame (cumulated sum of local variables' sizes) bigger than a kilobyte or two.
[of course, there are valid exceptions to that heuristic]