diff options
Diffstat (limited to 'user/lib/ctoi.c')
-rw-r--r-- | user/lib/ctoi.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/user/lib/ctoi.c b/user/lib/ctoi.c new file mode 100644 index 0000000..efe4fec --- /dev/null +++ b/user/lib/ctoi.c @@ -0,0 +1,14 @@ +#include <stdlib.h> + +int ctoi(char c) +{ + if (c >= '0' && c <= '9') { + return c - '0'; + } else if (c >= 'A' && c <= 'Z') { + return c - 'A' + 10; + } else if (c >= 'a' && c <= 'z') { + return c - 'a' + 10; + } else { + return -1; + } +} |