string str("There are two needles in this haystack with in needles.");
string keyword;
cout << str << endl;
cout << "Enter Keyword : ";
cin >> keyword;
int k = keyword.length();
int n = str.find(keyword);
cout << "Search "<<keyword<<" at : "<<n << endl;
str.erase(str.begin(),str.begin()+n+k+1);
//cout << str << endl;
int m = str.find(keyword);
if(m != -1)
cout << "Search " << keyword << " at : " << m+n << endl;
ไม่มีความคิดเห็น:
แสดงความคิดเห็น