double free or corruption 3d array in C
问题 I get a 'double free or corruption' error while freeing up an 3d array. Can anyone please tell me where is the problem in the code? The size of the array is 2*N*N. Value of N here is 100. Even without casting, same result. Here is the code: // Mallocing double ***h = malloc(2 * (sizeof(double**))); for(i = 0; i < N; i++) { h[i] = malloc(N * sizeof(double*)); for(j = 0; j < N; j++) { h[i][j] = malloc(N * sizeof(double)); } } // Freeing for(i = 0; i < N; i++) { for(j = 0; j < N; j++) { free(h[i