2014-09-30 66 views

回答

0

让你开始的东西。

unsigned strtou(const char *s, unsigned base) { 
    unsigned y = 0; 
    while (*s) { 
    unsigned digit; 
    if (isdigit(*s)) digit = ch - '0'; 
    else if (isupper(*s)) digit = ch - 'A' + 10; 
    else if (islower(*s)) digit = ch - 'a' + 10; 
    else Handle_IllegalDigit(); 
    if (digit >= base) Handle_IllegalDigit(); 

    y = y*base + digit; 
    s++; 
    } 
    return y; 
} 
+0

感谢那正是我需要的 – Alfred 2014-10-01 01:29:17