In C, how to convert a ASCII floating-point number to double ?
In C / C++,
atof() is a dedicated function for converting strings to floats (or doubles). First, include
Then, simply convert strings to floats (or doubles) :
char string = "10.66814";
float value = atof(string);
Test the previous code online on OneCompiler.
If the first sequence of non-whitespace characters in string does not form a valid floating-point number, the function