I have the following code which works fine for N=10 and C=25 but bombs with a segmentation fault if I use N=50 and C=25500
#include <stdio.h> #include <stdlib.h> // create table int *table; table = (int *) malloc(sizeof(int) * C+1 * N+1); if(table == NULL){ printf("[ERROR] : Fail to allocate memory.\n"); } // initialize table for(i =0; i < N-1; i++){ for(j = 0; j < C-1; j++){ //table[i*(C+1)+j]=0; *(table + (i*(C+1)+j))=1; } } printf("table made\n");
main()?if(table == NULL)condition. Pls try this