C库函数strstr分析
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
------------*/
Life is strange.