#include #include char *mystrpbrk(const char *s, const char *e, const char t[]) { for ( ; s < e; ++s) { const char *p; for (p = t; *p; ++p) if (*s == *p) return (char *)s; } return NULL; } char *mystrrpbrk(const char *s, const char *e, const char t[]) { while (s < e) { const char *p, c = *--e; for (p = t; *p; ++p) if (c == *p) return (char *)e; } return NULL; } int main(void) { const char s[] = "EDCBABCDE"; const char *e = s + sizeof s - 1; const char *t = "BCD", *p; if ((p = mystrrpbrk(s, e, t)) != NULL) printf("%d\n", (int)(p - s + 1)); if ((p = mystrpbrk(s + 3, e, t)) != NULL) printf("%d\n", (int)(p - s + 1)); if ((p = mystrpbrk(s + 4, s + 6, t)) != NULL) printf("%d\n", (int)(p - s + 1)); return 0; }