tags:

views:

382

answers:

1
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?

+16  A: 

Indeed there is:

std::istringstream iss(values);
std::copy(std::istream_iterator<int>(iss), 
          std::istream_iterator<int>(), 
          std::back_inserter(array));
Johannes Schaub - litb
Yep, right on target.I feel more educated already.Thank you.
EvilTeach