Talk:Determine if a string is numeric: Difference between revisions

no edit summary
No edit summary
Line 1:
== Subtle bug in the C example? ==
 
Carefully reading the ''strtol()'' man page on my Linux box I see that the entire resulting string was converted to a long '''if''' (and only if) *endptr (p in the example) is '\0' (an ASCII NUL) '''and''' if the *nptr (s in the example) was NOT '\0'. In other words I think the example should test for a precondition to return false if it's called with an empty string as the argument. If I were more confident in my C coding skills and my understanding of this particular function (and of the conformance of Linux to any relevant standards) I would insert a line like: ''if *s == '\0' return !*s;''
 
Am I mistaken?
 
[[User:JimD|JimD]] 16:16, 11 October 2007 (MDT)
 
== Unix shell ==
 
Anonymous user