Considering
char myarray[10];
You can use STLiterator :
vector <char> v;
copy(myarray, myarray + 10, back_inserter(v));
You can use constructor :
vector <char> v(myarray, myarray + 10);
You can resize and copy :
vector<char> v(10);
copy(myarray, myarray + 10, v.begin());
(and they all work similarly for a string)
Thanks to comments and other answers :)
source
share