Commit | Line | Data |
---|---|---|
f2be8b67 BJ |
1 | /* @(#)strcatn.c 4.1 (Berkeley) %G% */ |
2 | /* | |
3 | * Concatenate s2 on the end of s1. S1's space must be large enough. | |
4 | * At most n characters are moved. | |
5 | * Return s1. | |
6 | */ | |
7 | ||
8 | char * | |
9 | strcatn(s1, s2, n) | |
10 | register char *s1, *s2; | |
11 | register n; | |
12 | { | |
13 | register char *os1; | |
14 | ||
15 | os1 = s1; | |
16 | while (*s1++) | |
17 | ; | |
18 | --s1; | |
19 | while (*s1++ = *s2++) | |
20 | if (--n < 0) { | |
21 | *--s1 = '\0'; | |
22 | break; | |
23 | } | |
24 | return(os1); | |
25 | } |