Convert String containing several numbers into integers

Posted by GobiasKoffi on Stack Overflow See other posts from Stack Overflow or by GobiasKoffi
Published on 2009-08-24T08:32:38Z Indexed on 2012/08/28 21:39 UTC
Read the original article Hit count: 163

Filed under:
|
|

I realize that this question may have been asked several times in the past, but I am going to continue regardless.

I have a program that is going to get a string of numbers from keyboard input. The numbers will always be in the form "66 33 9" Essentially, every number is separated with a space, and the user input will always contain a different amount of numbers.

I'm aware that using 'sscanf' would work if the amount of numbers in every user-entered string was constant, but this is not the case for me. Also, because I'm new to C++, I'd prefer dealing with 'string' variables rather than arrays of chars.

© Stack Overflow or respective owner

Related posts about c++

Related posts about string