CONTENTS | INDEX | PREV | NEXT
atoi
atol
NAME
atoi - convert string into integer
atol - convert string into long integer
SYNOPSIS
#include <stdio.h>
#include <stdlib.h>
int x = atoi(str);
long y = atol(str);
const char *str;
Under DICE, sizeof(int) == sizeof(long), and thus these two routines
are exactly the same.
FUNCTION
atoi() and atol() convert a string of a base 10 integer number into
an integer. It skips initial white space, processes an optional
negative sign ('-'), then processes digits '0' - '9', return the
integer.
Both atoi() and atol() are superceeded by the strtol() function which
can handle numbers of any base. Please refer to the strtol()
manual page.
EXAMPLE
#include <stdio.h>
#include <stdlib.h>
main()
{
int i = atoi(" tt -123");
printf("i = %d (-123?)n", i);
return(0);
}
INPUTS
char *str; string to convert to int
RESULTS
int x; integer result
long y; integer result
SEE ALSO
strtol