Date: Sun, 3 May 1998 17:55:16 +0300 (IDT) From: Eli Zaretskii To: Oon Lin cc: djgpp AT delorie DOT com Subject: Re: Testing for float or int In-Reply-To: <35481B84.167E@jcu.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.