3 ms·
That was my first thought. No strncpy? Ok, while (*s1 && n--) { *s2++ = *s1++; } *s2 = '\0'; it is, then.
by commandlinefan 7y ago
That was my first thought. No strncpy? Ok,
while (*s1 && n--) {
*s2++ = *s1++;
}
*s2 = '\0';
it is, then.
- fwsgonzo 7y agoI 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/ https://blog.liw.fi/posts/strncpy/