home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / string / memchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-26  |  314 b   |  18 lines

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3. #include <libc/unconst.h>
  4.  
  5. void *
  6. memchr(const void *s, int c, size_t n)
  7. {
  8.   if (n)
  9.   {
  10.     const char *p = s;
  11.     do {
  12.       if (*p++ == c)
  13.     return unconst(p-1, void *);
  14.     } while (--n != 0);
  15.   }
  16.   return 0;
  17. }
  18.