Atof

From Wikipedia, the free encyclopedia

The correct title of this article is atof. The initial letter is shown capitalized due to technical restrictions.

The atof function in the C programming language is used to convert a string into a numerical representation.

double atof (const char *string)

Note that where as atoi and atol return variable types corresponding with their name ('atoI' integer and 'atoL' long integer), atof however, does not. Because of that, people tend to expect atof to return a floating point number, while in fact it returns a double.

Where string is the string, represented by an array of characters. When atof encounters a string with no numerical sequences, it returns a '0' (zero). Also, if the string where to hold a '0' as character, it would also return a '0', making it impossible to tell the difference between the two.

In other languages