代码:
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>
char*Strchr(const char*str, int ch)
{
assert(str);
char*pstr = (char*)str;
while (*pstr!='\0')
{
if (*pstr==ch)
{
return pstr;
}
pstr++;
}
return NULL;
}
int main()
{
char*p = "abcdcfg";
char*q=Strchr(p, 'c');
if (q != NULL)
{
printf("找到了\n");
printf("%s", q);
}
else
{
printf("没找到\n");
}
system("pause");
return 0;
}