zoukankan      html  css  js  c++  java
  • C 库函数

    C 库函数 - strstr()

    C 标准库 - <string.h> C 标准库 - <string.h>

    描述

    C 库函数 char *strstr(const char *haystack, const char *needle) 在字符串 haystack 中查找第一次出现字符串 needle 的地址,不包含终止符 ''。

    声明

    下面是 strstr() 函数的声明。

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

    参数

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

    返回值

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

    实例

    下面的实例演示了 strstr() 函数的用法。

    实例

    #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("子字符串是: %sn", ret);
      return(0);
    }

    让我们编译并运行上面的程序,这将产生以下结果:

    子字符串是: NOOB

    C 标准库 - <string.h> C 标准库 - <string.h>

  • 相关阅读:
    day01
    用表单验证数据(1)
    用表单验证数据
    表单
    ORM作业
    mysql完全卸载大全
    mycat特点及用途
    ajax 跨域请求解决方案
    myeclipse使用SVN团队开发
    配置mybatis错误总结
  • 原文地址:https://www.cnblogs.com/cqx6388/p/14261810.html
Copyright © 2011-2022 走看看