atof

From Wikipedia, the free encyclopedia

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 were to hold a '0' as character, it would also return a '0', making it impossible to tell the difference between the two.

Languages