首页 > 其他 > 详细

C 库函数 - strstr()

时间:2019-07-20 23:24:26      阅读:103      评论:0      收藏:0      [点我收藏+]

 

定义

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

C 库函数 - strstr()

原文:https://www.cnblogs.com/sea-stream/p/11219535.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!