I'm trying to execute this block of code.
#include <stdio.h>
int main(void)
{
printf("Start from here\n");
int e, f, g, h;
scanf("%d,%d", &e, &f);
scanf("%d, %d", &g, &h);
printf("%d %d %d %d", e, f, g, h);
}
When I input 2,0
or something that matches the format string in the first scanf()
, the second scanf()
also executes.
However, if I input something like 2-0
in the first scanf()
, the program skips the second scanf()
and goes straight to the printf()
For example, here's the input and output of a sample run of the program. The second line is the input.
Start from here
1-2
1 0 -2 -856016624u
Notice how the program completely skipped the second scanf()
, and went straight to the printf()
. Why is the second scanf()
being skipped over here?