Does scanf() have a known problem with floating points when used as below?
If it do 4.4 5.5 abc it fails like I want it to.Code:while( (scoresScanned = scanf("%f%f%f", &score1, &score2, &score3)) != EOF ){ if( scoresScanned == 3 ){ fflush(stdin); break; } else/.../ }
BUT
If I do 4.4 5.5 4abc5 it thinks I entered 4.0 as the last value.
My understanding of scanf() is that it should fail and return 2 in the latter case.
Why does scanf() do that? I hoped it would fail instead of truncate the input and append a .0. Perhaps there is a great document of this but I haven't found one.
I'm studying C in school which would explain why I'm asking about a deprecated function in the first place.
Thanks,
James
----
MS VC++ 2005 Express
C++ Language Extentions Off \Za
Compiling as C code \Tc



LinkBack URL
About LinkBacks


