Possible Duplicate:
C programming, why does this large array declaration produce a segmentation fault?
Why does this program crash? It works fine for a max of 1e6, and works fine if I don't set every value to 0.
Doesn't the program get all of the memory allocated?
int main() {
const int max = 10000000; // 1e7
int end[max];
unsigned int i;
for ( i = 0; i < max; i++ )
end[i] = 0;
}
$ gcc test.c && ./a.out
Segmentation fault (core dumped)