date and time created 80/12/21 16:39:26 by wnj
[unix-history] / usr / src / lib / libc / stdlib / atoi.c
CommitLineData
47eef4bc
BJ
1/* @(#)atoi.c 4.1 (Berkeley) %G% */
2atoi(ap)
3char *ap;
4{
5 register int n, c;
6 register char *p;
7 int f;
8
9 p = ap;
10 n = 0;
11 f = 0;
12loop:
13 while(*p == ' ' || *p == ' ')
14 p++;
15 if(*p == '-') {
16 f++;
17 p++;
18 goto loop;
19 }
20 while(*p >= '0' && *p <= '9')
21 n = n*10 + *p++ - '0';
22 if(f)
23 n = -n;
24 return(n);
25}