The caller can then examine the offending character and decide whether the string was valid or not. atoi, by contrast, just returns 0 if it got lost, which is not always helpful -- though if you are happy with this behaviour then you might as well use it.