std copy function in C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<int> copy_from_vector = {5, 7, 8, 9, 0, 10};
    vector<int> copy_to_vector(6);
    copy(copy_from_vector.begin(), copy_from_vector.begin() + 3, copy_to_vector.begin());
    for (auto el : copy_to_vector)
    {
        cout << el << endl;
    }

    return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *