Does a C string represent a VALID double ?????????

Hi guys !
I have a C string, and i need to convert it to a double.
I know i can use function atof()
**** BUT **********
I need to know whether or not the string represents
a VALID double ! (e.g. "8.112" is a valid double
whereas "8.aa2" is not).

Does anybody know how to make sure that the string
is a valid double ??????

Thanx a bunch for any suggestions !

-Kaylie

Comments

  • : Hi guys !
    : I have a C string, and i need to convert it to a double.
    : I know i can use function atof()
    : **** BUT **********
    : I need to know whether or not the string represents
    : a VALID double ! (e.g. "8.112" is a valid double
    : whereas "8.aa2" is not).
    :
    : Does anybody know how to make sure that the string
    : is a valid double ??????
    :
    : Thanx a bunch for any suggestions !
    :
    : -Kaylie
    :
    One way would be to iterate through the string 1 char at a time and test each char for being a digit or a decimal point (or 'e' if you allow exp notation).

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion