strncat.c 459 B

12345678910111213141516171819202122232425
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #include <string.h>
  7. char *
  8. strncat(char *ret, register const char *s2, size_t n)
  9. {
  10. register char *s1 = ret;
  11. if (n > 0) {
  12. while (*s1++)
  13. /* EMPTY */ ;
  14. s1--;
  15. while (*s1++ = *s2++) {
  16. if (--n > 0) continue;
  17. *s1 = '\0';
  18. break;
  19. }
  20. return ret;
  21. } else return s1;
  22. }