strstr用法
语法: #include <string.h> char *strstr(char *s1, char *s2);
作用:在s1中查找s2子串
返回s2在s1中第一次出现的地址,如果没找到则返回NULL。
匹配过程不包括NULL字符。
例子: #include <stdio.h> #include <string.h> int main () { char str[] ="This is a simple string"; char *pch; pch = strstr(str, "simple"); strncpy(pch, "sample", 5); puts(str); return 0; } 输出结果: This is a sample string