Add atoi()
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
int atoi(const char *str);
|
||||
|
||||
void *memcpy(void *restrict dst, const void *restrict src, size_t cnt);
|
||||
uint64_t *memcpyq(uint64_t *restrict dst, const uint64_t *restrict src, size_t cnt);
|
||||
void *memmove(void *dst, const void *src, size_t cnt);
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
#include "sys/string.h"
|
||||
#include "sys/ctype.h"
|
||||
|
||||
int atoi(const char *str) {
|
||||
int res = 0;
|
||||
while (isdigit(*str)) {
|
||||
res *= 10;
|
||||
res += (*str++) - '0';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
char *strcat(char *dst, const char *src) {
|
||||
size_t l = strlen(dst);
|
||||
|
||||
Reference in New Issue
Block a user