Link to home
Start Free TrialLog in
Avatar of koger
koger

asked on

String to float

How do I convert a string value to a float.
A small example would be great :)

Avatar of jacobkristensen
jacobkristensen

use the atof function:

float fVal = atof(strName);
Here is the code to convert string to double. (There no api available to convert the string to float directly.) Here is the code sample:

#include <stdlib.h>

main()
{
  char* str; *stopstr;

}
ASKER CERTIFIED SOLUTION
Avatar of Thangs
Thangs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
sorry, you have to use "strtod" instead of "strtol". Typing mistake.

Thangs
=> koger
Would you mind telling me why you didn't like my answer?