字符查找函数strchr
char *mystrchr(const char *str, const char c){ char *p = NULL; for (char*newp = str; *newp != '\0'; newp++) { if (*newp==c) { p = newp;//一个一个的查找 break; } } return p;}char *mystrchrdg(const char *str, const char c){ if (*str!='\0') { return NULL; } else { if (*str==c) { return str;//返回指针 } mystrchrdg(++str, c);//循环区域终止 }}//mystrchrvoid main(){ char *pstr1 = mystrchr("zrf is rocket", 'z'); char *pstr2 = mystrchrdg("zrf is rocket", 'A'); printf("pstr2=%s\n", pstr2); if (pstr1 == NULL) { printf("can not find"); } else { printf("can find %p 存在此字符:%c\n", pstr1, *pstr1); } system("pause");}