This repository has been archived on 2021-07-03. You can view files and clone it, but cannot push or open issues or pull requests.
glovechat/src/server/util/string.c
2019-01-30 15:27:23 -06:00

25 lines
574 B
C

#include "string.h"
int axtoi(const char* str) {
int value = 0, i;
for(i = 0; i < strlen(str); ++i) {
value *= 16;
if(str[i] >= '0' && str[i] <= '9')
value += str[i] - '0';
else if(str[i] >= 'a' && str[i] <= 'f')
value += (str[i] - 'a') + 10;
else if(str[i] >= 'A' && str[i] <= 'F')
value += (str[i] - 'A') + 10;
}
return value;
}
int strcnt(const char* str, char c) {
int cnt = 0, i;
for(i = 0; i < strlen(str); ++i)
if(str[i] == c)
++cnt;
return cnt;
}