home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / dlibssrc / memchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-07-15  |  314 b   |  17 lines

  1. #include <stdio.h>
  2.  
  3. char *memchr(buf, c, cnt)
  4. register char *buf;
  5. register char c;
  6. register int cnt;
  7. /*
  8.  *    Search the first <cnt> bytes of <buf> for <c>.  Returns a pointer to
  9.  *    the matching character, or NULL if not found.
  10.  */
  11. {
  12.     while(cnt--)
  13.         if(*buf++ == c)
  14.             return(--buf);
  15.     return(NULL);
  16. }
  17.