串匹配

//BF 算法
int BFmatch(char *s,char *p)
{
    int i,j;
    i = 0;
    while(i<strlen(s))
    {
        j = 0;
        while(s[i] == p[j] && j<strlen(p))
        {
            i++;
            j++;
        }
        if(j == strlen(p))
        return i - strlen(p);
        i = i - j + 1;   // 指针 i回溯
    }
    return -1;
}
原文地址:https://www.cnblogs.com/yangyongqian/p/3912523.html