Though the method suggested by
lastchance is a good one, and the way I would have suggested, there are alternatives.
What if for example the first part is an address which contains numbers? You don't want to misidentify a number within the address as a sales figure.
Read one line at a time, for example
Hong Kong 94 49 96 67 82 34 91 64 15 97 98 78 |
Then start from the end of the string, find the position of the last numeric character, in this example it would be the digit '8'. Starting from that position, find the position of the previous space. That takes you to the space between "98 78".
Now repeat that another eleven times, find a digit, find a space. After doing it 12 times, you will have the position of the space just before the first number. Now you can split the string (using substr() function), the first part is the name, the last part is the numbers.
After that, to get the numbers from the string, the easiest way is to use a stringstream.
references with examples:
http://www.cplusplus.com/reference/string/string/find_last_of/
http://www.cplusplus.com/reference/sstream/istringstream/istringstream/