In addition to this answer by pmg that explains how strto... has more functionality and error checking, the ato... functions are guaranteed by the standard to behave like this (C17 7.22.1.2):
Except for the behavior on error, they are equivalent to
atoi: (int)strtol(nptr, (char **)NULL, 10) atol: strtol(nptr, (char **)NULL, 10) atoll: strtoll(nptr, (char **)NULL, 10)
That being said, ato... are not required to call strto... internally (though this is the case in many libs), just to behave identically save for the error handling.
Please note that the ato... functions are not formally listed as obsolete yet. But they should be avoided still, mainly because it is pointless to use atoi when we can as well use strtol(str, NULL, 10), the latter being identical but with better error handling.
atoisill works..atoi("20")should return20. The problem is in your code which you didn't show. Edit your question and show a minimal reproducible example. Also read this: How to Askatoi()function might be deprecated, but it does still work just fine: exampleatoiusesstrtolor not is irrelevant.atoidoes what the documentation says, no more and no less. The bug is in your code. Maybeatoiis too limited for your usage, we don't know without seeing some source code.atoihas been used for decades. If at a moment in your programatoi("20")returns0, it is just an evidence that anywhere in the program you have Undefined Behaviour. C is a low level language, and consequences of UB are not necessary local. That is even the reason why it is called Undefined Behaviour...atoi("20")with a literal string in it. It's more likely to bestoi(str), where you think thatstrshould be"20", but don't check. Your comment that "in the first iteration it works and in the second iteration it doesn't" makes it clear: The problem is in your code.