1. Topic
implement strchr
2. Program code
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <Windows.h>
#include <assert.h>
char* my_strchr(char *obj, const char ori)
{
assert(obj);
while (*obj != ori)//当obj所指向的元素与ori不等时执行该循环
{
obj++;
}
return obj;//返回obj此时的地址
}
int main()
{
char arr[] = "abcdefg";
printf("%s\n", my_strchr(arr, 'd'));
system("pause");
return 0;
}