20 lines
276 B
C
20 lines
276 B
C
|
#include <stdbool.h>
|
||
|
#include "include/stdlib.h"
|
||
|
|
||
|
int atoi(const char* s) {
|
||
|
bool neg = false;
|
||
|
if(*s == '+') {
|
||
|
s++;
|
||
|
} else if(*s == '-') {
|
||
|
neg = true;
|
||
|
s++;
|
||
|
}
|
||
|
int n = 0;
|
||
|
while(*s >= '0' && *s <= '9') {
|
||
|
n *= 10;
|
||
|
n += (*s - '0');
|
||
|
s++;
|
||
|
}
|
||
|
return neg ? -n : n;
|
||
|
}
|