#include <iostream>
#include <string>
#include<conio.h>
using namespace std;
int main ()
{
string str ="Umer is a good programmer";
string str3;
string Replas;
int i=0;
char search_word[100];
cout << "enter Word For search : ";
cin >> search_word;
while(search_word[i]!='\0')
{
i++;
}
size_t found = str.find(search_word);
if (found!=string::npos)
{
cout << "-----------------------------------------------"<< endl;
cout << "Location found for search Elements : " << found << '\n';
cout << "-----------------------------------------------"<< endl;
cout << "number of elements are :"<< i<< endl;
cout << "-----------------------------------------------"<< endl<< endl;
cout << "Enter Word for replace....";
cin >> Replas;
str.replace(found,i,Replas);
cout << endl;
cout << "-----------------------------------------------"<< endl;
cout << str<< endl;
cout << "-----------------------------------------------"<< endl;
}
else
{
cout << endl;
cout << "-----------------------------------------------"<< endl;
cout << "sorry word not found"<< endl;
cout << "-----------------------------------------------"<< endl;
}
getch();
}
#include <string>
#include<conio.h>
using namespace std;
int main ()
{
string str ="Umer is a good programmer";
string str3;
string Replas;
int i=0;
char search_word[100];
cout << "enter Word For search : ";
cin >> search_word;
while(search_word[i]!='\0')
{
i++;
}
size_t found = str.find(search_word);
if (found!=string::npos)
{
cout << "-----------------------------------------------"<< endl;
cout << "Location found for search Elements : " << found << '\n';
cout << "-----------------------------------------------"<< endl;
cout << "number of elements are :"<< i<< endl;
cout << "-----------------------------------------------"<< endl<< endl;
cout << "Enter Word for replace....";
cin >> Replas;
str.replace(found,i,Replas);
cout << endl;
cout << "-----------------------------------------------"<< endl;
cout << str<< endl;
cout << "-----------------------------------------------"<< endl;
}
else
{
cout << endl;
cout << "-----------------------------------------------"<< endl;
cout << "sorry word not found"<< endl;
cout << "-----------------------------------------------"<< endl;
}
getch();
}