I can't understand what's happening. I created a matrix following this post: Function to dynamically allocate matrix
To print the matrix, I created this function:
void PrintMatrix(uint8_t *matrix, size_t nrows, size_t ncols)
{
// Prints matrix
size_t i, j;
printf("\n");
for (i = 0; i < nrows; ++i)
{
for (j = 0; j < ncols ; ++j)
{
printf("%" PRIu8 "\t", matrix[i][j]);
}
printf("\n");
}
printf("\n");
}
This function results in a compilation error:
error: subscripted value is neither array nor pointer nor vector
printf("%" PRIu8 "\t", matrix[i][j]);
In order to check the function, I copied the code inside main() and ran it, suprisingly without any problem, so, why it doesn't work when run as a separated function?