I am trying to make a function to calculate the transpose of a matrix of ints. The function takes the two dimensions of the matrix, those being d1 and d2, and the matrix itself, named arr, as well a a matrix called dest, which will be the transpose. Here's the code that I am trying to use:
void transpose(size_t d1, size_t d2, int arr[d1][d2], int dest[d2][d1])
{
for (size_t i = 0; i < d1; i++)
{
for (size_t j = 0; j < d2; j++)
{
dest[j][i] = arr[i][j];
}
}
}
And here is what I get when I try to compile:
Exercicios\source\9.52.c:5:48: error: use of parameter outside function body before ']' token
void transpose(size_t d1, size_t d2, int arr[d1][d2], int dest[d2][d1])
^
Exercicios\source\9.52.c:5:52: error: use of parameter outside function body before ']' token
void transpose(size_t d1, size_t d2, int arr[d1][d2], int dest[d2][d1])
^
Exercicios\source\9.52.c:5:53: error: expected ')' before ',' token
void transpose(size_t d1, size_t d2, int arr[d1][d2], int dest[d2][d1])
~ ^
)
Exercicios\source\9.52.c:5:55: error: expected unqualified-id before 'int'
void transpose(size_t d1, size_t d2, int arr[d1][d2], int dest[d2][d1])
Seeing this, one would probably say that I simply can't use the value of an argument in another argument, and it is what I thought the same, however, this function seems to work an online compiler and using the arguments as dimensions for other arguments was suggested on another question, as well as some articles here and there, so it must be (sort of) right. Even then, it does not work on my compiler(mingw-w64), so I was hoping anybody could help me figure this out.