FreeBSD/sys/libkern/strncpy.c
/*
 * Copy src to dst, truncating or null-padding to always copy n bytes.
 * Return dst.
 */
Copy src to dst, truncating or null-padding to always copy n bytes.
Return dst.
Copy src to dst truncating or null - padding to always copy n bytes . Return dst .
char *
strncpy(char * __restrict dst, const char * __restrict src, size_t n)
{
	if (n != 0) {
		register char *d = dst;
		register const char *s = src;
		do {
			if ((*d++ = *s++) == 0) {
				while (--n != 0)
					*d++ = 0;
				break;
			}
		} while (--n != 0);
	}
	return (dst);
}
char * strncpy ( char * __restrict dst , const char * __restrict src , size_t n ) { if ( n != 0 ) { register char * d = dst ; register const char * s = src ; do { if ( ( * d ++ = * s ++ ) == 0 ) { while ( -- n != 0 ) * d ++ = 0 ; break ; } } while ( -- n != 0 ) ; } return ( dst ) ; }
Copy src to dst, truncating or null-padding to always copy n bytes.
Copy src to dst truncating or null - padding to always copy n bytes .
/* NUL pad the remaining n-1 bytes */