In the following program though most of the working part of the program is commented out, it gives seg fault. reducing the value of MAX to say 10000 removes the seg fault. Why is this happening? it should be only 1 MB only. Is 1 MB too big for an array?
#include <stdio.h>
#define MAX 1000010
int main()
{
int m;
int n;
int carry;
int sum;
int i, j;
int n1[MAX];
int n2[MAX];
char r[MAX];
scanf("%d", &n);
//for (i = 0;i < n;i++)
//{
//scanf("%d", &m);
//for (j = 0;j < m;j++)
//{
// scanf("%d %d\n", &n1[j], &n2[j]);
//}
carry = 0;
/*for (j = m-1;j >= 0;j--)
{
sum = n1[j]+n2[j]+carry;
if (sum >= 10) {
sum -= 10;
carry = 1;
}
else
{
carry = 0;
}
r[j] = sum+'0';
}
r[m] = '\0';
if (carry == 1)
{
printf("1%s\n\n", r);
}
else
{
printf("%s\n\n", r);
}*/
//}
return 0;
}