I am trying to input values into a 3x3 matrix using pointers instead of using index. Below is my main program:
int main() {
int mat[ROW][COL];
int *p = &mat[0][0];
minput(p, ROW, COL);
return 0;
}
And this is my minput function:
void minput(int *m, int row, int col) {
// 1 2 3
// 4 5 6
// 7 8 9
*(m+0) = 1;
}
What I cant figure out is how to input the rest of the matrix, like [1][1]. I tried *(*(p+1)+1)
to try and access m[1][1] but it didnt seem to work. I hope this is clear.