Y
Hacker News
new
|
ask
|
show
|
jobs
by
commandlinefan
2494 days ago
That was my first thought. No strncpy? Ok,
while (*s1 && n--) { *s2++ = *s1++; } *s2 = '\0';
it is, then.
1 comments
fwsgonzo
2494 days ago
I don't think strncpy is the function you are looking for, either. Its for zeroing fixed-size character buffers. And it doesn't indicate problems.
https://blog.liw.fi/posts/strncpy/
link
https://blog.liw.fi/posts/strncpy/