C庫函數strstr分析

C標準庫<string.h>函數

函數聲明:
char* strstr(char* const _String, char const* const _SubString)code

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

示例:io

#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
------------*/
相關文章
相關標籤/搜索