#include <iostream>
#include <string>
int main()
{
std::string str[] = { "16 / 07 / 2016 John NewYork Fever Steve 30",
"16 / 07 / 2016 Michael NewYork Food Poisoning Mike 40",
"16 / 07 / 2016 Michelle Washington Flu Steve 50",
"16 / 07 / 2016 Jack NewYork Fever Mike 30",
"16 / 07 / 2016 Jackky California Fever Steve 70",
"16 / 07 / 2016 Malaysia California Fever Mike 50" };
std::cout << "Enter your search string: ";
std::string search;
std::getline(std::cin, search);
for (int i = 0; i < 6; i++)
{
std::string::size_type found = str[i].find(search);
if (found != std::string::npos)
{
std::cout << "first '" << search << "' found at: " << found
<< " in string[" << i << "]\n";
}
}
}
Enter your search string: ever
first 'ever' found at: 58 in string[0]
first 'ever' found at: 58 in string[3]
first 'ever' found at: 58 in string[4]
first 'ever' found at: 58 in string[5]