xref: /csrg-svn/lib/libc/string/strncat.c (revision 22116)
1 #ifndef lint
2 static char sccsid[] = "@(#)strncat.c	5.1 (Berkeley) 06/05/85";
3 #endif not lint
4 
5 /*
6  * Concatenate s2 on the end of s1.  S1's space must be large enough.
7  * At most n characters are moved.
8  * Return s1.
9  */
10 
11 char *
12 strncat(s1, s2, n)
13 register char *s1, *s2;
14 register n;
15 {
16 	register char *os1;
17 
18 	os1 = s1;
19 	while (*s1++)
20 		;
21 	--s1;
22 	while (*s1++ = *s2++)
23 		if (--n < 0) {
24 			*--s1 = '\0';
25 			break;
26 		}
27 	return(os1);
28 }
29