blob: fffc11819a006510a66a391eab1fab940367a2e0 [file] [log] [blame]
/*
* strncpy.c
*/
#include <string.h>
char *strncpy(char *dst, const char *src, size_t n)
{
char *q = dst;
const char *p = src;
char ch;
while (n) {
n--;
*q++ = ch = *p++;
if (!ch)
break;
}
/* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
memset(q, 0, n);
return dst;
}