hi, i came across this code:
Code:
#include <stdio.h>
#define N 3
typedef int matrix[N+2][N+2];
void initial_matrix(matrix m) // initiate the matrix
{
int i,j;
for (i=0;i<=N+1;i++)
{
for(j=0;j<=N+1;j++)
{
m[i][j] = -1; //*(&m[0][0]+i*(N+1)+j)
}
}
}
void print_matrix(matrix m) // prints the matrix
{
int i,j;
for (i=0;i<=N+1;i++)
{
for(j=0;j<=N+1;j++)
printf("%d ",m[i][j]);
printf("\n");
}
}
void main(void) {
matrix mat;
initial_matrix(mat);
print_matrix(mat);
system("pause");
}
guys, could you explain me how exacly the function "initial_matrix(mat)" works? (this code is written in C), why is it affecting the original variable mat?
(and isn't making a copy), what is sent to the function, and how does it receives it?
thanks in advance,
erik