I have an assignment in which I have to input dimensions of the first matrix, then which operation i would like to perform('-', '+' or '*'; subtraction, addition and multiplying respectively), and after that dimensions of the second matrix. But after entering first dimensions, I receive error message related to char. I cannot figure it out, even after reading a lot about whitespaces and errors related to scanf. Please help. Thank you
int main(void){
int rows_1 = 0, columns_1 = 0; //MATRIX_1 DIM
int rows_2 = 0, columns_2 = 0; //MATRIX_2 DIM
char c = ' ';
if(scanf("%d %d", &rows_1, &columns_1)!=2) //input first size
{
fprintf(stderr, "Error!\n");
return 100;
}
scanf("%c", &c);
if( c!='*' || c!='-' || c!='+' ) //error handling for char
{
fprintf(stderr, "Error!\n");
return 100;
}
if(scanf("%d%d", &rows_2, &columns_2)!=2) //input second size
{
fprintf(stderr, "Error!\n");
return 100;
}
return 0;
}