write atoi()
Anonimo
// should be OK for base 10 int atoi(char* string) { int val = 0; // check if value is negative bool negative = *string == '-'; // skip sign if(negative || *string = '+') string++; while(*string) { // accumulate digits val = 10*val + (*string - '0'); string++; } // remember to check for sign if(negative) val = -val; return val; }