strncpy.c 215 B

1234567891011121314151617
  1. #include <lib9.h>
  2. char*
  3. strncpy(char *s1, char *s2, long n)
  4. {
  5. int i;
  6. char *os1;
  7. os1 = s1;
  8. for(i = 0; i < n; i++)
  9. if((*s1++ = *s2++) == 0) {
  10. while(++i < n)
  11. *s1++ = 0;
  12. return os1;
  13. }
  14. return os1;
  15. }