Searching a word present in a sentence or not, if present print its location with a successful note.
#include <iostream>
#include <cstring>
using namespace std;
int main(){
string str="I am a C++ Programmer";
string str1="am";
//int x=find_str(str,str1);
cout<<"x\n";
void find_str(string main,string search) {
int i;
int x=find_str(str,str1);
int found=-1;
string s=main.split(" ");
for(i=0;i<s.length;i++)
{
if(search.equals(s[i]))
found=i+1;
}
return found;
};
}
Comments
Leave a comment