Extracting numbers from a string
Greetings. My problem here is not that urgent, but still, it's one that for some reason, still gives me headaches. It's like this:
I am entering some numbers from the keyboard, like this: 1 13 2 3 4 5. And I want to store them in a dynamically allocated vector. As you see here, there are 6 numbers. Parsing the string, I have to inform the compiler I have 6 numbers, so that will alocate memory for a vector holding exactly 6 numbers, like:
Code:
numbers = new int[6];
.
After that, I want to store those numbers in it. No matter how many spaces there are in the string, I just want those numbers stored in an array. If this is complicated or takes too much time to explain, then pass over it, but I would appreciate any help.
Thanks in advance.