totn C Functions

C Language: atof function
(Convert String to Floating-Point)

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.

Syntax

The 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).

Returns

The 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 Header

In the C Language, the required header for the atof function is:

#include <stdlib.h>

Applies To

In the C Language, the atof function can be used in the following versions:

  • ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the atof function:

See Also

Other C functions that are noteworthy when dealing with the atof function: