KMP string algorithm c++