Sorry i am new to c, i am trying to pass this matrix to a procedure by reference so i don't have to copy it in memory. I couldn't find any explanation. This is the closest i could get but it doesn't work. The point of the program is only for that, i made it to test it.
#include <stdio.h>
typedef int tmatrix[5][5];
void print (tmatrix*mtr)
{
int l , m;
l=0;
while (l<=4)
{
m=0;
while (m<=4)
{
printf("%d", *mtr[l][m]);
m = m+1;
}
printf("\n");
l=l+1;
}
}
//-----------------------------------
int main()
{
int i , j;
tmatrix matrix;
i=0;
while (i <= 4)
{
j=0;
while (j<=4)
{
matrix[i][j] = 3;
j = j+1;
}
i = i+1;
}
print(&matrix);
return 0;
}
It should print:
33333
33333
33333
33333
33333
But it prints:
33333
54198992041990930
1977890592-1961670060002752492
03232520
664-21479789407743168
I know it may be something to do with the pointers because i think those are addresses, but i got no clues.