Martin von Gagern <martin.vgag...@gmx.net> writes: > sc_prohibit_atoi_atof: > ---------------------- > > The comment claims that [fs]?scanf doesn't provide error feedback. The > "return value" section of my scanf(3) man page says differently: the > number of successful conversions is returned, which is quite a suitable > error indication in many cases, I believe.
The feedback that scanf lacks is whether the individual values converted are in the correct range for the types to which they are assigned. The C standard says scanf yields undefined behavior if the user provides an out-of-range value: 7.19.6.2 The fscanf function ...the result of the conversion is placed in the object pointed to by the first argument following the format argument that has not already received a conversion result. If this object does not have an appropriate type, or if the result of the conversion cannot be represented in the object, the behavior is undefined. This is definitely irritating. -- Ben Pfaff http://benpfaff.org