You could make use of the following if-statements:
- Hexadecimal:
if(('0'<=c && c<='9') || ('a'<=c && c<='f'))
- Decimal:
if(('0'<=c && c<='9'))
- Octal:
if(('0'<=c && c<='8'))
Edit:: 'c' is a character variable ( char
) of course :P
Just put them in a loop and evaluate each string character by character before doing the actual conversion :)
P.S.: Sorry if my explanation is bad, my native language is Dutch so my English vocabulary is a bit limited ...