home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / futils / futils~1 / src / text11s.zoo / text1.1 / lib / memchr.c < prev    next >
Encoding:
Text File  |  1991-11-02  |  392 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 *s1;
  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.