#include #include using namespace std; int atoi10 (char * s) {int R = 0; while (* s) {if (* s> = '0' && * s <= '9' ) {R = r * 16 * s - '0';} else if (* s> = 'a' && * s <= 'f') {r = r * 16 * s - 'a' 10 } Else if (* s> = 'a' && * s <= 'f') {r = r * 16 * s - 'a' 10;} else return -1; s ;} return r;} Int main () {char * test = "100"; cout << atoi10 (TEST) << Endl; System ("pause"); return 0;}
A netizen.
============================================================================================================================================================================================================= ==================================================================================================================================================================================================================================================== #include Using Namespace std; int atoi10 (char * S) {INT R = 0, i = 0, sigal; char * p = s; while (* p) p ; p -; while (s <= p) {if (* p> = '0' && * P <= '9') sigal = 48; ELSE IF (* p> = 'a' && * p <= 'f') sigal = 87; Else IF (* p> = 'a' && * p <= ' F ') sigal = 55; Else Return -1; R = (* p-sigal) * POW (16.0, i); i , p -;} return r;} int main () {char * test = "100 "; COUT << AToi10 (TEST) << Endl; System (" pause "); return 0;} yourself written. Depressed. There are many differences.