Exception thrown error in c -
i'm trying make one-dimension array 89401 elements in c:
double **a = (double**)malloc(89401*sizeof(double*)); (i = 0; i<89401; i++) a[i] = (double*)malloc(89401*sizeof(double));
but keep getting error:
exception thrown @ 0x003f61e0 in final project 2.exe: 0xc0000005: access violation writing location 0x00000000.
i can't figure out what's problem. searched site asked questions none of them contributed me.
if there handler exception, program may safely continued.
you have made 2 mistakes. first is, said, try create "1d array in size of 89401". in fact try allocate 89401*89401 doubles, seems 2d array. @mikecat wrote huge number, 89401*89401*8 bytes, if have 8 byte doubles. second not handle when memory allocation malloc not successful, i.e. when result null.
Comments
Post a Comment