Char to int conversion in C - Stack Overflow
As others have suggested, but wrapped in a function: int char_to_digit(char c) { return c - '0'; } Now just use the function. If, down the line, you decide to use a different method, you just need to change the implementation (performance, charset differe...