I have used this web link as reference.
The following code is generating this debug error:

I am unable to find the bug. Please help me.
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#define ROWS 3
#define COLS 5
main()
{
char ** my2dArray = NULL;
int i=0;
int j=0;
my2dArray = (char**) malloc(sizeof(char) * ROWS);
for(i=0 ; i<ROWS ; i++)
{
my2dArray[i] = (char*) malloc(sizeof(char) * COLS);
}
for(i=0 ; i<ROWS ; i++)
{
for(j=0 ; j<COLS ; j++)
{
my2dArray[i][j] = (i + 1) * (j + 1);
}
}
for(i=0 ; i<ROWS ; i++)
{
for(j=0 ; j<COLS ; j++)
{
printf("%d, ", my2dArray[i][j]);
}
printf("\n");
}
for(i=0 ; i<ROWS ; i++)
{
free(my2dArray[i]);
}
free(my2dArray);
system("PAUSE");
}
You are storing items of type
char*inmy2dArray[i]:charis 1 byte,char*is 4 or 8 byte, so you’re not allocating enough memory formy2dArrayat the moment, change it to this: