home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / string / memccpy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-01  |  384 b   |  20 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3.  
  4. void *
  5. memccpy(void *t, const void *f, int c, size_t n)
  6. {
  7.   c &= 0xff;
  8.   if (n)
  9.   {
  10.     unsigned char *tt = (unsigned char *)t;
  11.     const unsigned char *ff = (const unsigned char *)f;
  12.  
  13.     do {
  14.       if ((*tt++ = *ff++) == c)
  15.     return tt;
  16.     } while (--n != 0);
  17.   }
  18.   return 0;
  19. }
  20.