K
Keith Thompson
Tim Rentsch said:(e-mail address removed) (Richard Bos) writes: [...]In other words, it may in theory well be that atoi() is less likely to
have damaging undefined behaviour than gets(); but in practice, anyone
who even spends time pondering that likelihood instead of immediately
going for strtol() is a fool.
Perhaps so. But someone who doesn't distinguish between actual
behavior and Standard-specified behavior is a bigger fool.
I certainly do distinguish between actual behavior and
Standard-specified behavior. This does not lead me to conclude
that atoi() is appropriate in anything other than toy programs or
situations where the argument is tightly controlled (and in the
latter case, it's generally not worth the effort).
What is the actual behavior of atoi("99999999999999999999999999")?
How do you know? Are you sure it will remain the same on any
implementation your code is ever used with?