3 ms·
> What do people get out of pedantic rants such as this? Anyone who's written anything in C is quite aware of the issue here. Unfortunately, that's not the cas
by _kst_ 11y ago
> What do people get out of pedantic rants such as this? Anyone who's written anything in C is quite aware of the issue here.
Unfortunately, that's not the case.
I presume this link was posted here as a result of my recent comment on the "Don't Learn C the Wrong Way" article, which recommends strncpy() and strlcpy() as safer alternatives to strcpy().
I've see a number of calls to strncpy(). I've rarely seen such calls explicitly null-terminate the destination array. I've even seen things like
strncpy(dest, src, strlen(src));
which is certainly no safer than strcpy().
What I get out of this particular pedantic rant is an opportunity to let C programmers know that strncpy() isn't what they might thing it is (as well as a mention on the front page of Hacker News!).