C 库函数 - strstr()

https://www.runoob.com/cprogramming/c-function-strstr.html

#include <stdio.h>
#include <string.h>
 
 
int main()
{
   const char haystack[20] = "RUNOOB";
   const char needle[10] = "NOOB";
   char *ret;
 
   ret = strstr(haystack, needle);
 
   printf("子字符串是: %s\n", ret);
   
   return(0);
}

该函数返回在 haystack 中第一次出现 needle 字符串的位置,如果未找到则返回 null。

posted @ 2024-04-27 22:34  流水江湖  阅读(3)  评论(0编辑  收藏  举报