How can I count the number of rows and cols in c language after dynamic allocation?
void printMatrix(int **arr)
{
int i,j;
int col = (sizeof(arr)/sizeof(arr[0]));
int row = (sizeof(arr)/sizeof(arr[0][0]));
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("%d\t",arr[i][j]);
}
printf("\n");
}
}
In my example I get only the matrix start pointer by **arr
.
It try to run this code but it return row = 1
and col = 1
when the row = 3
and col = 2
.