summaryrefslogtreecommitdiffstats
path: root/share/tests/libc-str-cpy-stp/stpe/001/test.c
blob: 02b4896b99905836a61635f595eccccec5cdc9fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <c/str/cpy/stp/stpe/stpecpy.h>

#include <stddef.h>
#include <stdio.h>

int
main(void)
{
	char    buf[BUFSIZ];
	char    *p, *end;
	size_t  len;

	end = buf + sizeof(buf);
	p = buf;
	p = c_stpecpy(p, end, "Hello ");
	p = c_stpecpy(p, end, "world");
	p = c_stpecpy(p, end, "!");
	if (p == end) {
		p--;
		puts("Truncated:");
	}
	len = p - buf;
	printf("%zu: ", len);
	puts(buf);
}