summaryrefslogtreecommitdiff
path: root/lib/libc/string/strncat.c
blob: 1a957e432e29ca3cba8b60a565ea09afb83aaa61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <string.h> // for strncat, size_t

char *strncat(char *restrict s1, const char *restrict s2, size_t n)
{
	char *dest = s1;
	const char *src = s2;

	while (*dest != '\0')
		dest++;

	while (*src != '\0' && n > 0) {
		*dest++ = *src++;
		n--;
	}

	*dest = '\0';

	return s1;
}