// Program: string_matching.cpp
// find the first occurrence of a fixed pattern within the
// input text, and output the text read so far
#include
#include // strings are sequences of characters
// with array functionality
#include // for std::noskipws
// POST: returns window, after removing the first character and
// appending next as a new last character
std::string advance (std::string window, const char next)
{
int last_index = window.length()-1;
for (int i=0; i> std::noskipws; // don't skip whitespaces!
char c; // next character to be read
while (std::cin >> c) {
std::cout << c;
window = advance (window, c);
if (window == pattern) break;
}
std::cout << "\n";
return 0;
}