pointers-memory · intermediate · ~15 min
String → integer conversion, the classic interview problem.
Implement int my_atoi(const char *s) that converts a string of optional spaces, an optional +/- sign, and decimal digits to an int. Stop at the first non-digit. Do not handle overflow (assume the input is in range).
int my_atoi(const char *s) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.