It's part of a program I have done. When you type in the numbers you have to make a space (or enter) between every number example "8 9 0 1... " In order to make it work. What I want is that the user just can type "8901..." and its stores the same as when you type "8 9 0 1..". I can do this with a string but then it doesn't stores as a integer.
I hope you understand what I want to do. Here is the whole program if it's any help. So you can see what the program does:
atoi isn't an ideal solution. As on failure it'll return 0. But in a lot of cases 0 is a valid result that could be used.
As I posted a link that illustrates how to use a string-stream to accomplish the conversion. On failure this will throw an exception that can be handled accordingly.
Thanks for the link! But I can't get this to work with a vector. It would be nice if someone could write down the code. Because I'm getting crazy. I've tested everyting I can come up with but nothing wroks :(
I have not programmed for so long in C++ so that's why I may seem a little slow ;)