Hi, suppose I would use the following code (just the body, of course in reality I would also use the prinf function to communicate but I leaved that out of the code for simplicity)
int a;
int b;
char c;
scanf("%d", &a);
scanf("%c", &c);
scanf("%d", &b);
Somehow the scanf function remembers the newline that gets there after entering integer a and uses that newline as the input for the second one.
If however I would place a space like this then it works fine:
int a;
int b;
char c;
scanf("%d", &a);
scanf(" %c", &c);
scanf("%d", &b);
I know that the scanf function isn't ideal for jobs like this but I just want to understand how it works, why does that space make the difference?
My teacher did explain that that space would be nessecary to "eat up the newline" (unfortunately he chose to use english even though it is a foreign language to him).
Can someone please make sense of this?