]> git.ipfire.org Git - thirdparty/glibc.git/blob - manual/examples/strncat.c
509be49c9740f9d83c180231be565051368fe91c
[thirdparty/glibc.git] / manual / examples / strncat.c
1 /* strncat example.
2 Copyright (C) 1991-2015 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <string.h>
19 #include <stdio.h>
20
21 #define SIZE 10
22
23 static char buffer[SIZE];
24
25 int
26 main (void)
27 {
28 strncpy (buffer, "hello", SIZE);
29 puts (buffer);
30 strncat (buffer, ", world", SIZE - strlen (buffer) - 1);
31 puts (buffer);
32 }