Last change
on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
592 bytes
|
Rev | Line | |
---|
[3ae31e9] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | strncat.c -- concatenate strings
|
---|
| 4 | Version 1 -- 1987-06-12
|
---|
| 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 |
|
---|
| 12 | char *
|
---|
| 13 | strncat(s1, s2, n)
|
---|
| 14 | register char *s1, *s2;
|
---|
| 15 | register int n;
|
---|
| 16 | {
|
---|
| 17 | register char *os1;
|
---|
| 18 |
|
---|
| 19 | os1 = s1;
|
---|
| 20 |
|
---|
| 21 | while(*s1++)
|
---|
| 22 | ;
|
---|
| 23 |
|
---|
| 24 | --s1;
|
---|
| 25 |
|
---|
| 26 | while(*s1++ = *s2++)
|
---|
| 27 | if(--n < 0) {
|
---|
| 28 |
|
---|
| 29 | *--s1 = '\0';
|
---|
| 30 | break;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | return(os1);
|
---|
| 34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.