In the C Programming Language, the atof function converts a string to a floating-point number (double).
The atof function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.
SyntaxThe syntax for the atof function in the C Language is:
double atof(const char *nptr); Parameters or Arguments nptr A pointer to a string to convert to a floating-point number (double). ReturnsThe atof function returns the floating-point representation of a string. The atof function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.
Required HeaderIn the C Language, the required header for the atof function is:
#include Applies ToIn the C Language, the atof function can be used in the following versions:
ANSI/ISO 9899-1990 Similar FunctionsOther C functions that are similar to the atof function:
atoi function atol function strtod function See AlsoOther C functions that are noteworthy when dealing with the atof function:
strtol function strtoul function