Created
May 23, 2016 20:15
-
-
Save steveobbayi/fc399e6e59d48664b248a4f6ca2b3719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<int> src = {2,5,3}; // our source of data | |
vector<int> dest = {0,0,0,0,0,0,0,0,0,0}; // array to be modified | |
// Lets copy all of src to dest | |
copy(src.begin(), src.end(),dest.begin()); | |
// dest is now {2,5,3,0,0,0,0,0,0,0} | |
// lets copy part of src to dest | |
copy_n(src.begin(), 2, dest.begin()); | |
// dest is now {2,5,0,0,0,0,0,0,0,0} | |
//lets copy to the end of dest | |
copy_backward(src.begin(), src.end(),dest.end()); | |
//dest is now {0,0,0,0,0,0,0,2,5,3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment