define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
#include

char my_strchr01(char str,char ch)
{
int i = 0;
while (str[i])
{
if (str[i] == ch) {
return &str[i];
}
i++;
}
return NULL;
}
char my_strchr(char str, char ch)
{
while (str)
{
if (
str == ch)
return str;
str++;
}
return NULL;
}
int main()

{
char str[] = “hello world”;
char* p = my_strchr(str, ‘h’);
if (p == NULL) {
printf(“未找到\n”);
}
else {
printf(“%s\n”,p);

  1. }<br /> return 0;<br />}