metal-cos/lib/libc/stdlib.c

20 lines
238 B
C
Raw Normal View History

2023-08-20 23:05:08 +00:00
int
atoi(const char *nptr)
{
int i = 0;
int val = 0;
while (nptr[i] != '\0') {
if (nptr[i] >= '0' && nptr[i] <= '9') {
val = val * 10 + (int)(nptr[i] - '0');
} else {
return 0;
}
i++;
2023-08-20 23:05:08 +00:00
}
return val;
}