mirror of
https://github.com/UzixLS/KernelEx.git
synced 2025-07-18 23:11:19 +03:00
25 lines
316 B
C
Executable File
25 lines
316 B
C
Executable File
/*
|
|
* 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;
|
|
}
|