A different approach to get a solution to string matching with O(n) time complexity.
I have added the program for Knuth Morris Pratt Algorithm and the new program, you can compare both the programs time taken on your machine.
Thierry Lecroq maintains a large array of string matching algorithms proposed by different people here. I think BMH (Horspool in the list) is the fastest in most cases.
The inputs for C and Python programs are hard coded. You need to change them manually.