home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / DLIBSSRC.ZIP / STRNCPY.C < prev    next >
Encoding:
Text File  |  1987-06-14  |  438 b   |  18 lines

  1. char *strncpy(dest, source, limit)
  2. register char *dest;
  3. register char *source;
  4. register int limit;
  5. /*
  6.  *    Copies the <source> string to the <dest>.  At most, <limit>
  7.  *    characters are copied.  If <source> ends before <limit> characters
  8.  *    have been copied, the '\0' is copied, otherwise <dest> is not
  9.  *    terminated by the copy.
  10.  */
  11. {
  12.     register char *p = dest;
  13.  
  14.     while((limit--) && (*dest++ = *source++))
  15.         ;
  16.     return(p);
  17. }
  18.