[英]String Comparisons - C
I'm trying to write a string routine in C, and I keep hitting on the same issue. 我试图用C编写一个字符串例程,但我仍然遇到同样的问题。
In C, I have this string: 在C中,我有以下字符串:
MAMAAMAAALJ
If I have this string: 如果我有这个字符串:
AAA
How can I determine that AAA is inside of MAMAAMAAAJ? 如何确定AAA在MAMAAMAAAJ内部?
Many C
runtime libraries contain the function strstr (const char *s1, const char *s2) . 许多C
运行时库都包含函数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. 如果s2在s1内,则它将在s1内返回一个指向子字符串开头的指针,否则返回NULL。
strstr("MAMAAMAAAJ", "AAA");
返回指向搜索字符串出现的指针,如果未找到则返回NULL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.