查找字符串是我们平常编程过程中经常遇到的,现在介绍一种查找字符串算法,增加程序的执行速度。
通常我们是这么写的:
/* content: search a string in a othor string author: lw date: 2015-01-30 target: kmp algorithm */ #include <stdio.h> #include <string.h> void compare(char * sourcestr, char * targetstr) { char *moveSource, *moveTarget, *headPoint; int num = 0; headPoint = sourcestr; moveSource = sourcestr; moveTarget = targetstr; while(*headPoint != *moveTarget) headPoint++; moveSource = headPoint; while(*moveSource != '