标签:循环 pst 字符串 tracking else null name har mil
字符查找函数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);//循环区域终止 } } //mystrchr void main() { char *pstr1 = mystrchr("zrf is rocket", 'z'); char *pstr2 = <span style="font-family: Arial, Helvetica, sans-serif;">mystrchrdg</span>("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"); }
标签:循环 pst 字符串 tracking else null name har mil
原文地址:http://www.cnblogs.com/wzjhoutai/p/7209175.html