strrchr.c 548 B

1234567891011121314151617181920212223242526272829
  1. /* Portable version of strrchr().
  2. This function is in the public domain. */
  3. /*
  4. @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
  5. Returns a pointer to the last occurrence of the character @var{c} in
  6. the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
  7. null character, the results are undefined.
  8. @end deftypefn
  9. */
  10. #include <ansidecl.h>
  11. char *
  12. strrchr (register const char *s, int c)
  13. {
  14. char *rtnval = 0;
  15. do {
  16. if (*s == c)
  17. rtnval = (char*) s;
  18. } while (*s++);
  19. return (rtnval);
  20. }