I think that might work. My method makes more sense to me but that's because it's just the first thing that came to mind when thinking about the problem.
Your method means you only need to walk the string once which is better. Either way 9/10 interview candidates can't even get that far.
You can work from the front of the string to the end and multiply your accumulated result by 10 at each step, can't you?
I might just be misunderstanding your wording, in which case ignore me.