blob: c43b88c881c534fc069546be5a2e5067e355a02e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <stddef.h>
char *strncpy(char *restrict s1, const char *restrict s2, size_t n)
{
char *result = s1;
while (n > 0 && *s2 != '\0') {
*s1++ = *s2++;
n--;
}
if (n > 0)
*s1 = '\0';
return result;
}
|