home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / libnix.lha / gnu / lib / libnix / sources.lha / nix / string / memchr.c next >
Encoding:
C/C++ Source or Header  |  1994-06-09  |  240 b   |  16 lines

  1. #include <string.h>
  2.  
  3. void *memchr(const void *s,int c,size_t n)
  4. {
  5.   if (n != 0)
  6.   {
  7.     unsigned char *p=(unsigned char *)s;
  8.     do
  9.     {
  10.       if (*p++==(unsigned char)c)
  11.         return --p;
  12.     }while(--n != 0);
  13.   }
  14.   return (void *)n;
  15. }
  16.