3 ms·
For those similarly curious: """ char * STRNCPY (char s1, const char s2, size_t n) { size_t size = __strnlen (s2, n); if (size != n) memset (s1 + s
by chris_va 8y ago
For those similarly curious:
"""
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);
}
libc_hidden_builtin_def (strncpy)
"""
... which is actually different than how I thought it would be implemented (it ends up with an extra loop to figure out the size of the string).
(side note, how does one format code in HN?)
- kazinator 8y ago> how does one format code in HN? Two space indent.