home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / MEMRCHR.C < prev    next >
Text File  |  1984-12-31  |  768b  |  28 lines

  1. /*  File   : memrchr.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 25 May 1984
  4.     Defines: memrchr()
  5.  
  6.     memrchr(src, chr, len)
  7.     searches the memory area pointed to by src extending for len bytes,
  8.     looking for an occurrence of the byte value chr.  It returns NullS
  9.     if there is no such occurrence.  Otherwise it returns a pointer to
  10.     the LAST such occurrence.
  11.  
  12.     See the "Character Comparison" section in the READ-ME file.
  13. */
  14.  
  15. #include "strings.h"
  16.  
  17. char *memrchr(src, chr, len)
  18.     register char *src;
  19.     register int chr;        /* should be char */
  20.     register int len;
  21.     {
  22.     register char *ans;
  23.     for (ans = NullS; --len >= 0; src++)
  24.         if (*src == chr) ans = src;
  25.     return ans;
  26.     }
  27.