Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int htoi (char s[]) {
- int i,j,n;
- i = j = n = 0;
- char hex[] = "0123456789abcdef"; /*the array of possible hexadecimal digits*/
- if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) /*skip over the optional 0x or 0X*/
- i = 2;
- for ( ;s[i] != '\0'; i++) {
- for (j = 0; j <= 16; j++) {
- if ((s[i] == hex[j]) || (s[i] == toupper(hex[j])))
- n = 16*n + j;
- }
- }
- return n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement