ATOF(S) UNIX System V ATOF(S)
Name
atof, atoi, atol - converts ASCII to numbers
Syntax
#include <math.h>
double atof (nptr)
char *nptr;
#include <stdlib.h>
int atoi (nptr)
char *nptr;
long atol (nptr)
char *nptr;
Description
These functions convert a string pointed to by nptr to
floating, integer, and long integer numbers respectively.
The first unrecognized character ends the string.
atof recognizes a string of the form:
[ +| - ] digits[. digits ][ e| E [ +| - ] digits ]
where the digits are contiguous decimal digits. Any number
of tabs and spaces may precede the string. The + and -
signs are optional. Either e or E may be used to mark the
beginning of the exponent.
atoi and atol recognize strings of the form:
[ +| - ] digits
where the digits are contiguous decimal digits. Any number
of tabs and spaces may precede the string. The + and -
signs are optional.
See Also
scanf(S)
Notes
There are no provisions for overflow.
These routines must be linked by using the -lm linker
option.
Standards Conformance
atof, atoi and atol are conformant with:
AT&T SVID Issue 2, Select Code 307-127;
The X/Open Portability Guide II of January 1987;
and ANSI X3.159-198X C Language Draft Standard, May 13,
1988.
(printed 6/20/89)