On Mon, Jun 29, 2009 at 11:41:04PM -0400, James K. Lowden wrote:
I fail to see how sscanf(3) is more error prone than strtonum(). No
matter what, you have to specify -- via the name or the format string --
the format of the input and of the receiving buffer. At least with
sscanf(3) that's *all* you have to do.
Correct use of sscanf() for a single integer is something like:
count = sscanf(inbuf, "%i%n", &int_val, &byte_count);
if (count != 2 || inbuf[byte_count] != 0)
/* Conversion error */
I'm not sure that it is possible to detect numeric overflow.