home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / misc / textutil.lha / textutils-1.3 / lib / memchr.c < prev    next >
Encoding:
Text File  |  1992-06-30  |  391 b   |  20 lines

  1. /* memchr.c -- compare memory.
  2.    Return address of first C in S, or NULL if not found.
  3.    Stops looking after N characters.  Doesn't stop at nulls.
  4.    In the public domain.
  5.    By David MacKenzie <djm@ai.mit.edu>. */
  6.  
  7. char *
  8. memchr (s, c, n)
  9.      register char *s;
  10.      register char c;
  11.      register unsigned n;
  12. {
  13.   while (n--)
  14.     {
  15.       if (*s++ == c)
  16.     return s - 1;
  17.     }
  18.   return 0;
  19. }
  20.