I asked my problem here The largest size of 2-D array in C and what I got answer there before declaration as duplicate by some people, I modified my code like this:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,j,n,m,p = 0 ;
int sum[100000] = {0};
scanf("%d%d%d",&n,&m,&p);
/*for ( i = 0 ; i < n ; i++ )
{
for( j = 0 ; j < m ; j++ )
{
a[i][j] = j + 1 ;
}
}*/
int **a = (int **) malloc(sizeof(int)*n);
for(i=0; i<n; i++)
{
a[i] = (int *) malloc(sizeof(int)*m);
for(i=0; i<n; i++){
for(j=0; j<m; j++){
a[i][j] = j + 1 ;
}
}
}
return 0;
}
But still I am getting the same segmentation fault.Please help me to fix it and I hope this question will not be declared as duplicate. :P