Gary Wessle wrote in message ...
>"Alf P. Steinbach" <al***@start.nowrites:
>* Gary Wessle:
whats an efficient way to copy a string[] to a vector<string>?
how about this?
#include <iostream>
#include <string>
#include <vector>
Using namespace std;
int main(){
string s[] = { "aaa", "bbb", "ccc" };
vector<stringv( s.begin(), s.end() );
cout << v[1] << endl;
}
That won't compile.
yes, it did not compile.
// ------------
#include <iostream>
#include <ostream>
#include <string>
#include <vector>
int main(){
std::string B[]={"001","2","we","the world"};
// std::vector<std::stringvBstr;
// std::copy( B, B+(sizeof B/sizeof *B), std::back_inserter( vBstr ) );
std::vector<std::stringvBstr( B, B+(sizeof B/sizeof *B) );
for( size_t i(0); i < vBstr.size(); ++i ){
std::cout << vBstr.at( i ) <<std::endl;
}
} // main()
// ------------
--
Bob R
POVrookie