Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8622 | Boppan | 1 | /* strncat( char *, const char *, size_t ) |
2 | |||
3 | This file is part of the Public Domain C Library (PDCLib). |
||
4 | Permission is granted to use, modify, and / or redistribute at will. |
||
5 | */ |
||
6 | |||
7 | #include |
||
8 | |||
9 | char * strncat( char * s1, const char * s2, size_t n ) |
||
10 | { |
||
11 | char * rc = s1; |
||
12 | |||
13 | while ( *s1 ) |
||
14 | { |
||
15 | ++s1; |
||
16 | } |
||
17 | |||
18 | while ( n && ( *s1++ = *s2++ ) ) |
||
19 | { |
||
20 | --n; |
||
21 | } |
||
22 | |||
23 | if ( n == 0 ) |
||
24 | { |
||
25 | *s1 = '\0'; |
||
26 | } |
||
27 | |||
28 | return rc; |
||
29 | } |