[Solved] Segmentation fault occurs in C program
[ad_1] As sjsam pointed out, this statement is wrong: arr=(int **) malloc(sizeof(int )*n); Your program works on systems where sizeof(int) == sizeof(int*) (i.e. 32-bit systems), but will likely fail on 64-bit ones (on which sizeof(int) == 4 and sizeof(int*) == 8. i want to create a 2d array dynamically of dimension n by q We … Read more