当前位置: 移动技术网 > IT编程>开发语言>C/C++ > C库函数strstr分析

C库函数strstr分析

2019年12月06日  | 移动技术网IT编程  | 我要评论

若邻,水锻法,乐巢汇论坛

c标准库<string.h>

函数声明:
char* strstr(char* const _string, char const* const _substring)

返回值:
substring在string中第一次出现的位置,直到末尾,不包括\0

示例:

#include <stdio.h>
#include <string.h>

int main()
{

    char a[10] = "hello";
    char b[5] = "ll";
    char* ret = strstr(a, b);

    printf("%s, %p\n%p\n%p", ret, ret, &a[2], &b[0]);
    return 0;
}


//结果:
/*------------
value of ret is: llo
addr of ret is: 00eff73a
addr of a[2] is:00eff73a
addr of b[0] is: 00eff728
------------*/

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网