I suggest you to carefully go through the following code of lines that can be helpful for you to get the information or knowledge of the replace_copy() function in the C++ language :
Code:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int mint[] = { 10, 20, 30, 30, 20, 10, 10, 20 };
vector<int> myvctr (8);
replace_copy (mint, mint+8, myvctr.begin(), 20, 99);
cout << "myvctr contains:";
for (vector<int>::iterator it=myvctr.begin(); it!=myvctr.end(); ++it)
cout << " " << *it;
cout << endl;
return 0;
}
Output:
Code:
myvctr contains: 10 99 30 30 99 10 10 99
Bookmarks