strncpy.c 235 B

1234567891011121314
  1. /* $Id$ */
  2. char
  3. *strncpy(s1, s2, n)
  4. register char *s1, *s2;
  5. int n;
  6. {
  7. /* Copy s2 to s1, but at most n characters. */
  8. char *original = s1;
  9. while (*s2 && n-- > 0) *s1++ = *s2++;
  10. while (n-- > 0) *s1++ = '\0';
  11. return(original);
  12. }