Indiegogo interview question

Write the base C function atoi(char* string) without using the built in transformation functions.

Interview Answer

Anonymous

5 July 2019

int atoi(const char* string) { int res = 0; while (*string) { res = res * 10 + (*string) - '0'; ++string; } return res; }

1