Sreekanth <sr*******@yahoo.com> wrote:
"Irrwahn Grausewitz" <ir*******@freenet.de> wrote in message
news:72********************************@4ax.com... "Sreekanth" <sr*******@yahoo.com> wrote: >Hello,
>Am trying to convert a string to float. Am using atof() for that purpose.
>But the return value for atof is same for the string "0.0" and for some
>invalid input "Invalid". Can any body suggest me the way to differentiate an >invalid float number string and a 0.0.
Instead of atof use strtod.
Thanks, But it also returns 0 in both cases.. I want to differentiate an
invalid string and a Zero string in a string to float conversion mechanism.
Well, that's why you should use strtod():
double strtod(const char *nptr, char **endptr);
If you got an illegal argument *endptr and nptr are identical after
the call of the function. On legal input what endptr points to is
a pointer to the part of the input string where the conversion
stopped and it differs from nptr.
Regards, Jens
--
\ Jens Thoms Toerring ___
Je***********@physik.fu-berlin.de
\__________________________
http://www.toerring.de