C Programming on the IBM PC (C Programmers Reference Guide Series)

atof

#include <stdlib.h>double atof(const char *str);

The atof( ) function converts the string pointed to by str into a double value. The string must contain a valid floating-point number. If this is not the case, the returned value is undefined.

The number can be terminated by any character that cannot be part of a valid floating-point number. This includes whitespace, punctuation (other than periods), and characters other than E or e. This means that if atof( ) is called with “100.00HELLO”, the value 100.00 will be returned.

Related functions are atoi( ) and atol( ).

Категории