strncat.c 209 B

12345678910111213141516171819
  1. #include <u.h>
  2. #include <libc.h>
  3. char*
  4. strncat(char *s1, char *s2, long n)
  5. {
  6. char *os1;
  7. os1 = s1;
  8. while(*s1++)
  9. ;
  10. s1--;
  11. while(*s1++ = *s2++)
  12. if(--n < 0) {
  13. s1[-1] = 0;
  14. break;
  15. }
  16. return os1;
  17. }