Though this is strange, but I am getting a segmentation fault while scanning an integer value.
Here is my program :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int t,n,i,j;
char c;
int grid[1000][1000],right[1000][1000],down[1000][1000];
scanf("%d",&t);
printf("hello\n");
while(t--)
{
scanf("%d",&n);
memset(right, 0, sizeof(int) * 1000 *1000);
memset(down, 0, sizeof(int) * 1000 *1000);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%c",&c);
printf("CHAR = %c\n", c);
if(c == '.')
grid[i][j] = 1;
else
grid[i][j] = 0;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d",grid[i][j]);
}
}
}
return 0;
}
Doing gdb
shows segmentation fault at line scanf("%d",&t);
. I cannot figure out how this is happening?
[Using gcc-4.8.4 on a linux 32-bit machine ]