Hi guys,
I tried to make a dynamic 2D array of char
as follow:
char** ppMapData = (char**)malloc(sizeof(char*)*iMapHeight);
for (int i=0; i< iMapHeight; i++)
{
ppMapData[i] = (char*)malloc(sizeof(char)*iMapWidth);
//do something
}
// do something
for (int i=0; i<iMapHeight; i++)
free(ppMapData[i]);
free(ppMapData);
It looks fine to me; however, when it comes to run time, my program crash at the line which calls free(ppMapData[i])
. Any ideas what is the problem here.
Thank you very much.