The program that can be listed below describes you about the replace() function of the C++ language and how you can use the replace() function in the C++ program as :
Code:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int mint[] = { 10, 20, 30, 30, 20, 10, 10, 20 };
vector<int> mvctr (mint, mint+8);
replace (mvctr.begin(), mvctr.end(), 20, 99);
cout << "mvctr contains:";
for (vector<int>::iterator t=mvctr.begin(); t!=mvctr.end(); ++t)
cout << " " << *t;
cout << endl;
return 0;
}
Output :
Code:
mvctr contains : 10 99 30 30 99 10 10 99
Bookmarks