strstr函数的详细讲解

定义:strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串。如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。

比如: 
char str2 = “cdef”; 
char str1 = “abcdefgh”; 
则通过函数,将返回 
strstr(str1,str2) = cdefgh;

如果str1不包含有str2。 
char str2 = “cxef”; 
char str1 = “abcdefgh”; 
则通过函数,将返回 
strstr(str1,str2) = NULL
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务