As far as i know this two ways to create a matrix should be identical:
First way:
int i;
int **matrix = (int**)malloc(R*sizeof(int*));
for (i=0; i<R; i++)
matrix[i] = (int*)malloc(C*sizeof(int));
Second way:
int matrix[R][C];
with R and C declared as:
#define R 3
#define C 5
My question is, when i pass the second way declared matrix to a function like this:
void myfunction(int **m, int rows, int columns);
with the code:
myfunction(matrix,R,C);
why does it give me a Segmentation fault as soon as i try to touch the values inside the matrix?
The same happens when i pass the first way declared matrix to a function like this:
void myfunction(int m[][C], int rows, int columns);
What am i missing?