#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
char str[] = "www.java2java.com";
vector<char> vectorObject, vectorObject2(30);
unsigned int i;
for(i = 0; str[i]; i++)
vectorObject.push_back(str[i]);
cout << "Input sequence:\n";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[i];
cout << endl;
remove_copy(vectorObject.begin(), vectorObject.end(), vectorObject2.begin(), ' ');
cout << "Result after removing spaces:\n";
for(i = 0; i <vectorObject2.size(); i++)
cout << vectorObject2[i];
cout << endl << endl;
cout << "Input sequence:\n";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[i];
cout << endl;
// replace spaces with colons
replace_copy(vectorObject.begin(), vectorObject.end(), vectorObject2.begin(), ' ', ':');
cout << "Result after repacing spaces with colons:\n";
for(i = 0; i <vectorObject2.size(); i++)
cout << vectorObject2[i];
cout << endl;
return 0;
}
|