banan-os/libc/string/strncpy.c

11 lines
213 B
C
Raw Normal View History

2022-11-12 23:47:06 +02:00
#include <string.h>
char* strncpy(char* restrict dest, const char* restrict src, size_t n)
{
size_t i;
for (i = 0; src[i] && i < n; i++)
dest[i] = src[i];
for (; i < n; i++)
dest[i] = '\0';
return dest;
}