1 #include <iostream>
2
3 int main()
4 {
5 constint m = 1000;
6 int a [m] [m];
7 for (int i=0; i < m; i++)
8 for (int j=0; j < m; j++)
9 a [i] [j] = 0;
10
11 int b [m] [m];
12 for (int i=0; i < m; i++)
13 for (int j=0; j < m; j++)
14 b [i] [j] = 0;
15
16 int c [m] [m];
17 for (int i=0; i < m; i++)
18 for (int j=0; j < m; j++)
19 c [i] [j] = 0;
20
21 return 0;
22 }
the above code gives
Segmentation fault (core dumped)
the program exits normally if
1) comment line 19 or replace it with ';' OR
2) line 5 'const int m = 100;'
if memory gets allocated on line 16, why seg fault upon accessing/writing the location.