Implement atoi: skip leading spaces, read an optional sign, read digits until a non-digit, and clamp the result to the 32-bit signed range [−2³¹, 2³¹−1]. Anything unreadable yields 0.
Input: one line, the raw string. Output: the parsed integer.
42
42
-042
-42
1337c0d3
1337
Parsing stops at 'c'.
words and 987
0
Run your code against the sample tests, or Submit to run the full suite.