What's so bad about scanf anyway???
Kim Christian Madsen
kimcm at diku.dk
Mon Nov 12 22:20:32 AEST 1990
rjc at uk.ac.ed.cstr (Richard Caley) writes:
>In article <VXogs2w163w at cybrspc> roy%cybrspc at cs.umn.edu (Roy M. Silvernail) writes:
> The problem with scanf() is that it can behave unpredictably when you
> give it badly formatted input. It's better, IMHO, to gets() a whole
> line, check its validity and _then_ sscanf() it into the target
> variables.
>Maybe it was just a typo, but repeat after me
> `GETS is EVIL'
>This has been un unpayed anouncement by paranoids anonymous.
gets can get you into a lot of trouble if used for in a non-controlled
manner, e.g. for user input. Then you be better off by using fgets or
reading char-by-char with getchar() or family. But using scanf() for user
input is asking for trouble!
Kim Chr. Madsen
just as
More information about the Comp.lang.c
mailing list