Don't use functions from ato... group. These are broken and virtually useless. A moderately better solution would be to use sscanf, although it is not perfect either.
To convert string to integer, functions from strto... group should be used. In your specific case it would be strtol function.