CS350 COS
COS
Loading...
Searching...
No Matches
stdlib.c File Reference

Go to the source code of this file.

Functions

int atoi (const char *nptr)
 

Function Documentation

◆ atoi()

int atoi ( const char *  nptr)

Definition at line 3 of file stdlib.c.

4{
5 int i = 0;
6 int val = 0;
7
8 while (nptr[i] != '\0') {
9 if (nptr[i] >= '0' && nptr[i] <= '9') {
10 val = val * 10 + (int)(nptr[i] - '0');
11 } else {
12 return 0;
13 }
14 i++;
15 }
16
17 return val;
18}
Here is the caller graph for this function: