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

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;
}