The following program can demonstrates you that how to use the remove_copy_if() function in the programming of the C++ language while doing the coding using the remove_copy_if() function as shown below :
Code:
#include <iostream>
#include <algorshm>
#include <vector>
using namespace std;
bool IOd (int i)
{
return ((i%2)==1);
}
int main ()
{
int mint[] = {1,2,3,4,5,6,7,8,9};
vector<int> mvctr (9);
vector<int>::serator s;
remove_copy_if (mint,mint+9,mvctr.begin(),IOd);
cout << "mvctr contains:";
for (s=mvctr.begin(); s!=mvctr.end(); ++s)
cout << " " << *s;
cout << endl;
return 0;
}
The Output of the above program as :
Code:
mvctr contains: 2 4 6 8 0 0 0 0 0
Bookmarks