I want to write contents of an array into a vector.
int A[]={10,20,30,40,50,60,70,80,90};
vector<int> my_vector;
Earlier I used to copy the contents of array A into another array B using memcpy. I want to use my_vector instead of array B
How to write contents of array A into my_vector in one shot without a for loop?
You can use
memcpy, or use such initialization in C++98/03.Also you can use algorithm, such as
copy.In C++11, use
std::begin(A),std::end(A)for begin and end of array.