home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / string / memchr.c next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  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.