函数返回指针类型(strchr函数)
作者:互联网
#include<stdio.h> #include<string.h> char *mystrchr(char *s,char c) { while(*s) { if(*s == c) { return s; } s++; } return NULL; } int main() { char str[100] = "hello world"; //char* s = strchr(str,'a'); char *s = mystrchr(str,'e'); //返回ello world字符串 printf("s = %s\n",s); return 0; }
标签:strchr,return,函数,mystrchr,char,str,world,指针 来源: https://www.cnblogs.com/wanghao-boke/p/11020398.html