#include <stdio.h>
#include <assert.h>
char* my_strchr(const char *s,char c){
assert(s != NULL);
while(*s!='\0'&&*s != c){
++s ;
}
return *s == c ?s : NULL;
}
int main() {
char string[1010], c;
scanf("%s %c", string, &c);
char* ptr = strchr(string, c);
if(ptr != NULL) {
printf("The character %c is at position: %s\n", c, ptr);
} else {
printf("The character was not found\n");
}
return 0;
}
strchr 查找字符串 str 中首次出现字符c的位置