#include <iostream>
#include <string>
using namespace std;
int main()
{
int i;
string stringObject1 = "Quick of Mind, Strong of Body, Pure of Heart";
string stringObject2;
i = stringObject1.find("Quick");
if(i!=string::npos) {
cout << "Match found at " << i << endl;
cout << "Remaining string is:\n";
stringObject2.assign(stringObject1, i, stringObject1.size());
cout << stringObject2;
}
cout << "\n\n";
i = stringObject1.find("Strong");
if(i!=string::npos) {
cout << "Match found at " << i << endl;
cout << "Remaining string is:\n";
stringObject2.assign(stringObject1, i, stringObject1.size());
cout << stringObject2;
}
cout << "\n\n";
i = stringObject1.find("Pure");
if(i!=string::npos) {
cout << "Match found at " << i << endl;
cout << "Remaining string is:\n";
stringObject2.assign(stringObject1, i, stringObject1.size());
cout << stringObject2;
}
cout << "\n\n";
// find list "of"
i = stringObject1.rfind("of");
if(i!=string::npos) {
cout << "Match found at " << i << endl;
cout << "Remaining string is:\n";
stringObject2.assign(stringObject1, i, stringObject1.size());
cout << stringObject2;
}
return 0;
}
|