#include #include using namespace std; int main() { string phrase{"Danger Danger Danger"}; string key{"Dan"}; //key = "Fred"; size_t position; position = phrase.find(key); while(position != string::npos) { cout <<"\"" << key << "\" is at position " << position << " in " << phrase << endl; position = phrase.find(key, position + 1); } /* if(position == string::npos) { cout << "Not found " << endl; } else { cout <<"\"" << key << "\" is at position " << position << " in " << phrase << endl; } */ return 0; }