开发者

String Comparisons - C

I'm trying to write a string routine in C, and I keep hitting on the sam开发者_StackOverflow中文版e issue.

In C, I have this string:

MAMAAMAAALJ

If I have this string:

AAA

How can I determine that AAA is inside of MAMAAMAAAJ?


Many C runtime libraries contain the function strstr (const char *s1, const char *s2).

If s2 is within s1, it returns a pointer within s1 to the beginning of the substring, otherwise returns NULL.


strstr("MAMAAMAAAJ", "AAA");

returns the pointer to the occurrence of the search string, or NULL if not found


Boyer–Moore string search algorithm


C realization

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜