Don't use atoi(). Use strtol(), strtoul(), etc. The last (third) argument passed to the function is the base. It will try to convert intelligently if the base is 0, so if the string is 0xCAFEFACE, it will look at the "0x" and convert from hex, where 01234567 would be treated as octal since it starts with zero and only has digits 0-7. If you pass a second non-null argument (char** endptr) the address of a string pointer, the pointer will be set to where in the passed number string the conversion stopped, such as when it encounters a letter or some other character. Anyway, the signatures are: