When learning C in simple programs it often happens that the computer skips the execution of some lines of code, and I can't understand why this is so.
Now as an example, I sketched a program which simply stores 3 numbers entered by the user:
#include <stdio.h>
int main(void)
{
int a, b, c;
printf("Please type in number a: \n");
scanf("%i", &a);
printf("Please type in number c: \n");
scanf("%i", &c);
printf("Please type in number b: \n");
scanf("%i", &b);
return 0;
}
I want to enter 1, 2, and 3. This is what I get in the console (in Ubuntu):
Please type in number a:
1
Please type in number b:
Please type in number c:
2
The input of number b was ignored.
Not only the second input is skipped, so even the input is in the wrong order. Initially, I wrote everything in alphabetic order in the code - a, b and c, then the input of b was skipped, and then I changed the order in the code and still, as you can see, the execution remained unchanged.
And such cases I have had earlier.
Why is this happening?