Indiegogo Interview Question

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

Interview Answer

Anonymous

Jul 5, 2019

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

1