|
two dimensional arrays in C
hey y'all!
so i was working on this little program, and got to the point where i have to let the user enter integers from the keyboard to fill in a 3x3 matrix. I declared my 3x3 matrix as a a two dimensional array thus:
int matrix[3][3];
and also
int i, j; //as counters
to fill this array i did:
for(i=0; i<3; i++) //rows of the matrix
{
for(j=0; j<3; j++) //columns of the matrix
{
printf("Enter a number to fill matrix [%d][%d]: ", i, j);
scanf("%d", &matrix[i][j]);
}
}
but the program won't compile!! I get an error message for the line with "scanf" saying "invalid binary operator"
is that an improper way to fill a two dimensional array from the keyboard during run time?
Please somebody help! I'm very confused here
Thanks a lot!
|