atoi() Convert String to Integer
#include <stdlib.h>
int atoi(string); The integer value of string
char *string; String to be converted
atoi() converts 'string' to an integer value. atoi() does not
recognize decimal points or exponents. 'string' has the following
format:
[whitespace][sign]digits
where
whitespace any number of tab or space characters;
sign + or -
digits one or more decimal digits.
Returns: The integer value of 'string'. If 'string' cannot be
converted to an integer, 0 is returned. The return value
is undefined for overflow.
-------------------------------- Example ---------------------------------
The following statements convert a string to an integer and print the
result.
#include <stdio.h>
char *s;
int i;
main()
{
s = "12345";
i = atoi(s);
printf("%d\n",i);
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster