char *values = " 3 1 4 15";
vector<int> array;
I want to populate the array with the values,
3,1,4,15
Is there a slick way to do it with the stl copy algorithm?
char *values = " 3 1 4 15";
vector<int> array;
I want to populate the array with the values,
3,1,4,15
Is there a slick way to do it with 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));