summaryrefslogtreecommitdiff
path: root/lib/libc/string/stpncpy.c
blob: 8f7ebd010b40957f75398bcd3bc9f9d14b81a585 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stddef.h>

char *strncpy(char *restrict s1, const char *restrict s2, size_t n)
{
	char *d = s1;

	while (n-- && *s2)
		*d++ = *s2++;

	while (n--)
		*d++ = '\0';

	return s1;
}