@Kooth:
Oh, I'm sorry about that.
In fact, I didn't mean it. I'm not a native speaker of English, so my wording might look harsh while in fact, I really don't mean it :)
This is the beginner's forum, I absolutely understand it, and I would atcually consider myself as a beginner as well.
You don't need to call convertToString >> number until after your "for" loop. |
With all my respects, I'd like to point out that your solution doesn't work. The reason, I believe, still lies in the erroneous usage of stringstream.
@waqqassheikh:
If my previous post makes you unhappy in anyway, my appologies. I didn't mean it.
I'm afraid I can't give you proposals until you give the requirement of the function. For example, if the string contains multiple numbers, like "I am 12 years old 10 years ago.", do you want to extract the two numbers as two numbers or simply 1210?
In addition, do you HAVE to use iterator of stringstream? etc.
As an exercise, you probably want to think about how to do it by yourself. In case you need more help, get back here with a more rigorous definition of the problem and we'll see how we can help.