果然
char *
STRNCPY (char *s1, const char *s2, size_t n)
{
size_t size = __strnlen (s2, n);
if (size != n)
memset (s1 + size, '\0', n - size);
return memcpy (s1, s2, size);
}
【 在 nwn 的大作中提到: 】
: 读读文档就知道了
: The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character isn't appended automatically to the copied string. If count is greater than t
: he length of strSource, the destination string is padded with null characters up to length count.
: ...................
--
FROM 182.150.115.*