Write a program (matching.cpp) which finds all occurrences of a given pattern within a text file using the Morris-Pratt algorithm. Instrument your algorithm to count the number of character comparisons performed. Extend your program to run two searches, the first using the original Morris-Pratt algorithm, and the second with extensions based on the character in the text that failed to match (the Knuth Morris-Pratt algorithm). Output the total number of comparisons performed in each case.
The name of the file and the pattern itself should be read directly from standard input, in that order. Example: Filename a one line ASCII pattern potentially involving spaces
For each algorithm, you should output The number of occurrences of the pattern in the text The position in the text where the first 10 occurrences of the pattern were found. Don't worry about trying to work out line and column numbers, the position should be the index in the file, so for example a position of 0 indicates that the pattern appears at the very beginning of the file. The number of character comparisons performed.