Atof (converts a string to a float number)
Related functions: atoi, atol, strtodd, strtol, strtoul
Header file # include <stdlib. h>
Define the function Double atof (const char * nptr );
Function Description: atof () scans the nptr parameter string and skips the leading space character until conversion starts when a number or positive or negative sign is encountered, the conversion ends only when a non-number or string ends ('\ 0') and the result is returned. The nptr string can contain positive and negative numbers, decimal points, or E (e) to represent the exponential part, such as 123.456 or 123e-2.
Return the number of floating point types after conversion.
The additional description atof () is the same as the use of strtodd (nptr, (char **) null.
Example/* convert string a and string B into numbers and add them together */
# Include <stdlib. h> main () {char * A = "-100.23"; char * B = "200e-2"; float C; C = atof (A) + atof (B ); printf ("C = %. 2f \ n ", c) ;}execute c =-98.23
Refer to Baidu knowledge