定义

char *strstr(const char *haystack, const char *needle)

参数

haystack -- 要被检索的 C 字符串。
needle -- 在 haystack 字符串内要搜索的小字符串

描述

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

 

例子

#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);
}

输出

子字符串是: NOOB

 

 

参考:

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

相关文章:

  • 2022-12-23
  • 2021-05-25
  • 2021-05-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2021-06-29
  • 2021-06-14
  • 2021-08-04
相关资源
相似解决方案