P
Peter Nilsson
Arctic said:... I am under the impression, perhaps, that scanf and such
functions have at them a group of people who are in at least
partially strong objection to their use? If so, is their some
history or methods or something else about these scanf tools
with which I am not familar that has earned them such apparent
dislike?
The problem lies with teachers and tutors who are too eager to
teach the entire language as quickly as possible, without focussing
on details. You'll often see newbies totally unaware of the basic
problems with code like...
scanf("%s", my_string);
...
The problem with scanf is that it is too easy to misuse, especially
if you're just using 'default' options. Of course, that doesn't mean
it can't be used correctly. It just means that people are prone to
prefering alternative tools.
Unfortunately, writing bullet proof input routines that deal with
both good and bad input robustly (without undefined behaviour), and
which are able to continue with further input (in the absense of EOF),
is not a trivial task in C!