最近在 复习C/C++部分知识,在准备着 招聘。。。。。
char * strchr(char * str, int ch) :功能就是找出在字符串str中第一次出项字符ch的位置,找到就返回该字符位置的指针,如果找不到就返回空指针(就是 null)。
代码实现:
char str[20]="Hello world";
char c = 'o';
printf("%s\n",strchr(str,c));
输出结果:o world
char * strstr(char * str1,char * str2);功能就是找出在字符串str1中第一次出项字符串str2的位置(也就是说字符串sr1中要包含有字符串str2),如果找不到就返回空指针(就是 null)。
代码实例:
char str[20]="Hello world";
char c[4] = "el";
printf("%s\n",strstr(str,c));
输出结果:ello world