This doesn't even look close to the code I've posted...
Why are you doing it this way? It looks ugly as hell, is bug prone and not easy maintainable.
Furthermore, atoi is old C rubbish and not safe at all. You sould use stringstreams for that aswell!
Doing so will allow you stuff like this:
This is by far the better solution.