and today I learned a function.header files: #include <string.h>
The Strstr () function is used to retrieve the first occurrence of a substring in a string, with the following prototype:
Char *strstr (char *str, char * substr);
"Parameter description" STR is the string to retrieve, substr is the substring to retrieve.
Return value returns the address of the first substring substr in STR, or null if no substring is retrieved.
The use of the function example Strstr () function.
#include <stdio.h> #include <string.h>int main () { //can also be changed to char str[] = "http://see.xidian.edu.cn/cpp/u /xitong/"; Char *str = "http://see.xidian.edu.cn/cpp/u/xitong/"; Char *substr = "See"; Char *s = strstr (str, substr); printf ("%s\n", s); return 0;}
Operation Result:
see.xidian.edu.cn/cpp/u/xitong/
This function is used in question 1238.
C language Strstr () function: Returns the address of the first occurrence of a substring in a string