strrchr
char *ho_strrchr(const char *s, int c) { const char *p; unsigned char cc = c; for (p = s; *p; p++); while (s <= p) { if (*p == cc) return (char *)p; p--; } return NULL; } int main() { printf("%s\n", ho_strrchr("123456789", ‘1‘)); printf("%s\n", ho_strrchr("123456789", ‘2‘)); printf("%s\n", ho_strrchr("123456789", ‘3‘)); printf("%s\n", ho_strrchr("123456789", ‘9‘)); printf("%s\n", ho_strrchr("123456789", ‘a‘)); printf("%s\n", ho_strrchr("123123", ‘1‘)); return 0; }
时间: 2024-10-08 05:09:06