I want to fill 2D array with random numbers and then call it in main function and print it. But I can't access the function FillMatrix from main.
#define R 12 //row
#define S 10 //column
void FillMatrix(int m[][S], int row);
int main(int argc, char *argv[])
{
int i, j;
time_t t;
// POINTER TO POINTER
int **mat = (int **)malloc(R * sizeof(int *));
if ((mat = (int**)malloc(R*sizeof(int))) == NULL)
{
printf("Error");
return 0;
}
for (i = 0; i<R; i++)
mat[i] = (int *)malloc(S * sizeof(int));
FillMatrix(mat, R); //<- This line is the problem
// RAND 0 - 1000
}
void FillMatrix(int m[][S], int row)
{
int i, j;
time_t t;
srand((unsigned)time(&t));
for (i = 0; i < row; i++)
for (j = 0; j < S; j++)
m[i][j] = rand() % 1000 + 0;
}
void FillMatrix(int m[][S], int row);before your main.malloc).