Definition | #include <stdlib.h> double atof(const char *s);
All control characters for white space are legal for tab (see definition of white space under | |
Return val. | Floating-point number of type | |
for strings formatted as described above and representing a numeric value that is within the permissible floating-point range. | ||
0 | for strings which do not correspond to the syntax described above. | |
HUGE_VAL | for strings whose numeric value lies outside the permissible floating-point range. In addition, | |
Notes | The decimal point (or comma) in the string to be converted is affected by the locale (category LC_NUMERIC). The decimal point is the default.
| |
Example | The following program converts a string passed in the call (Enter Options) into the #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) /* Numbers are passed as strings!! A conversion is */ /* required if the numeric value is needed */ { printf("floating : %f\n", atof(argv[1])); return 0; } | |
See also | atoi, atol, strtod, strtol, strtoul |