I tried with ideone related to the code that reads the numerical value with scanf () in C, but I did not understand the behavior well.
http://ideone.com/PJ1dU2
#include <stdio.h>
int main(void) {
int val;
scanf("%d", &val);
printf("val=%d\n", val);
scanf("%d", &val);
printf("val=%d\n", val);
scanf("%d", &val);
printf("val=%d\n", val);
return 0;
}
stdin
A
3
1
4
result
val=-1218232755
val=-1218232755
val=-1218232755
I didn't understand why the number 3
could not be read.
http://f4.aaacafe.ne.jp/~pointc/log460.html
If the character you are trying to scan does not match the conversion specification, the scanf function will do so. Leaves the characters in the stream unreadable.
That's what it is. It wasn't an ideone bug either.
Recommended Posts