Find specific string and return that string

1234567890123 1234567890123 sam WELCOME chris
1234567890123 1234567890123 chris WELCOME sam
1234567890123 1234567890123 luke WELCOME sam

so the text could be either of 3 above lines.

so i first need to scan for first occuring letter from either sam chris or luke
and return that letter.
I have decided to have seperate function for this. so far I have done:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  string isWanted(string & line1)
{

if (line1.find_first_of("sam"))
{ 
    line1 = ("sam");
}
else if (line1.find_first_of("luke"))
{
    line1 = ("luke");
}
else if (line1.find_first_of("chris"))
{
    line1= ("chris");
}
return line1;
}
Do you have a question?
Topic archived. No new replies allowed.