Mail Archives: djgpp/1998/05/03/10:57:12
On Thu, 30 Apr 1998, Oon Lin wrote:
> I had been surfing around Delorie's lib C online reference for a
> function that can test whether an input is in float or int.
One way of doing this is to call the functions `strtod' and `strtol'
on a string that's supposed to be the number and nothing else. These
functions return a pointer to after the last character of the string
that is still part of a legal number. So if that pointer points to
the terminating '\0' character, the entire number is in correct
format.
Since every int can be read as a double, but not the other way around,
calling `strtol' alone should supply the desired result.
- Raw text -