char *values = " 3 1 4 15"; vector<int> array;
I want to populate an array with values,
3,1,4,15
Is there a slick way to do this using the stl copy algorithm?
Indeed, there is:
std::istringstream iss(values); std::copy(std::istream_iterator<int>(iss), std::istream_iterator<int>(), std::back_inserter(array));