home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 387b.lha / dice_v2.02 / lib / string / strncpy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  290 b   |  29 lines

  1.  
  2. /*
  3.  *  STRNCPY.C
  4.  *
  5.  *  (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  */
  7.  
  8. #include <string.h>
  9.  
  10. char *
  11. strncpy(d, s, n)
  12. char *d;
  13. const char *s;
  14. {
  15.     char c;
  16.     char *base = d;
  17.  
  18.     while(n && (c = *s)) {
  19.     *d = c;
  20.     ++s;
  21.     ++d;
  22.     --n;
  23.     }
  24.     if (n)
  25.     *d = 0;
  26.     return(base);
  27. }
  28.  
  29.