I want to change my globally available 2d array to a malloc array and pass it to the following function
I have this 2d array as a global variable
char grid[ROW][COLUMN];
I want to pass it to this functionas a parameter, but using a malloc array
void draw_grid(int row, int col)
{
printf(" ");
for (int c = 0; c < col; ++c)
{
printf(" ");
printf(" %d", c);
// printf(" ");
}
printf("\n");
for (int r = 0; r < row; ++r)
{
printf("%d", r);
printf("|");
for(int dot = 0; dot < (row*col); ++dot)
{
grid[r][dot] = ' ';
printf("|");
printf("%c", grid[r][dot]);
printf(" ");
// Dots needs to remain within the grids bounds
if (dot == (col) - 1)
{
printf("|| \n");
//printf("\n");
break;
}
}
}
}