Pergunta de entrevista da empresa Microsoft

Explain how to test this code, write atoi, etc

Resposta da entrevista

Sigiloso

20 de nov. de 2014

int my_atoi(char * string) { int numArr[10]; int val = 0; int numChars = 0; while(*string) { if(*string >= '0' && *string <= '9') { numArr[numChars++] = (*string++) - '0'; } else string++; } for(int i = 0; i < numChars; i++) { val += numArr[i] * (int) pow(10,numChars - i - 1); } return val; }