array; I want to populate an array with values, 3,1,4,1...">

Fill the vector <int> from integers to char *

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?

+3
source share
1 answer

Indeed, there is:

 std::istringstream iss(values); std::copy(std::istream_iterator<int>(iss), std::istream_iterator<int>(), std::back_inserter(array)); 
+16
source

All Articles