C Programming/stdlib.h/atof< C Programming | stdlib.h(Redirected from C Programming/C Reference/stdlib.h/atof)
atof is a function in the C programming language that converts a string into a floating point numerical representation.
atof stands for ASCII to float. It is included in the C standard library header file
stdlib.h. Its prototype is as follows:
double atof (const char *str);
str argument points to a string, represented by an array of characters, containing the character representation of a floating point value. If the string is not a valid textual representation of a
atof will silently fail, returning zero (0.0) in that case. 
Note that while
atol return variable types corresponding with their name ("
atoi" returns an integer and "
atol" returns a long integer), atof however, does not return a
float, it returns a
A related function is sscanf. This function extracts values from strings and its return argument is the number of valid values it managed to extract (so, unlike
sscanf can be used to test if a string starts with a valid number).
- ISO/IEC 9899:1999 specification, p. 307, § 220.127.116.11