3 ms·
"always use strncpy" I disagree; you should almost never use strncpy. Its name implies that it's a "safer" version of strcpy, but that's not what it is at all.
by _kst_ 8y ago
"always use strncpy"
I disagree; you should almost never use strncpy. Its name implies that it's a "safer" version of strcpy, but that's not what it is at all. If the target array isn't big enough, it can easily end up not containing a null-terminated string.
As it happens, I wrote about this a few years ago.
http://the-flat-trantor-society.blogspot.com/2012/03/no-strncpy-is-not-safer-strcpy.html http://the-flat-trantor-society.blogspot.com/2012/03/no-strn...