welldefined
Programmer
Hi, Can you check what is wrong (must very simple) in the code. It got Debug Error when free().
#include <stdlib.h>
#include <stdio.h>
int main()
{
int nRow=10, nCol=5, i; double **a;
a = malloc(nRow * sizeof(double *));
for (i=0;i<nRow;i++)
a=malloc(nCol*sizeof(double *));
a[8][2]=12.3;
printf("%f",a[8][2]);
for (i=0;i<nRow;i++)
free(a);
free(a);
getchar();
return 0;
}
#include <stdlib.h>
#include <stdio.h>
int main()
{
int nRow=10, nCol=5, i; double **a;
a = malloc(nRow * sizeof(double *));
for (i=0;i<nRow;i++)
a=malloc(nCol*sizeof(double *));
a[8][2]=12.3;
printf("%f",a[8][2]);
for (i=0;i<nRow;i++)
free(a);
free(a);
getchar();
return 0;
}