Error while trying to initialize array /:
Hello,
I have just started learning C as a course i'm taking in univ'.
I need to make and manipulate a matrix (I assumed by using two-dimensional array) but when I try to declare and initialize it gives me a compiler error: "error C2143: syntax error : missing ';' before 'type' "
Now, I know what this error means but I have checked everything and tried to move the declaration around the code and it keeps giving me the same error.
I'm posting part of the code (the user is supposed to input the matrix dimensions which I still have not thought about how to do)
Code:
{
int row;
int col;
printf ("Please enter the matrix height ( number of rows ) :\n");
scanf ("%d", &row);
while (row < 2 || row > 15)
{
printf ("Wrong input, the matrix height must be between 2 and 15 - try again :\n");
scanf ("%d", &row);
}
printf ("Please enter the matrix width ( number of columns ) :\n");
scanf ("%d", &col);
while (col < 2 || col > 15)
{
printf ("Wrong input, the matrix width must be between 2 and 15 - try again :\n");
scanf ("%d", &col);
}
int mat [4][5];
As you can see, the array is really not related to any of the code above and is in the correct syntax (I think) and still it gives me the error...
I'll really appreciate any idea...