Here is a beautiful way to parse ints and store them in a vector, provided they are space delimited (from Split a string in C++?):
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
int main() {
    using namespace std;
    string s = "3 2 1";
    istringstream iss(s);
    vector<int> tokens;
    copy(istream_iterator<int>(iss),
         istream_iterator<int>(),
         back_inserter<vector<int> >(tokens));
}
Is it possible to specify another delimeter (eg ", ") while keeping something similar?
 
     
    