The problem is that people have religious wars about strncat vs strlcat, which are both terrible and both equally broken, rather than looking at the big picture.
strncat
How to use strncat in a sentence. Live example sentences for strncat pulled from indexed public discussions.
Editorial note
The problem is that people have religious wars about strncat vs strlcat, which are both terrible and both equally broken, rather than looking at the big picture.
Quick take
The problem is that people have religious wars about strncat vs strlcat, which are both terrible and both equally broken, rather than looking at the big picture.
Example sentences
Secondly, contrary to what the article implies, strncat() does not work this way: strncat() always null-terminates the destination, and it doesn't write any extra nulls.
The article also suggests using strncat for this: dest[0] = '\0'; strncat(dest, src, size);.
This is the same sort of argument as strlcat vs strncat, and people can't agree on that one.
It's not confusing when you realise that strncat() is not a concatenating analogue of strncpy().
The information in the strncpy() / strncat() section is incorrect.
The strncat() behavior is quite confusing.
I think it would have been worth using strncat.
For C: strncpy(), strncat(), snprintf() (or the non-standard asprintf()), and fgets(), respectively.
/s Quick, someone named strcat_s or strncat correct them!
This sequence: target[0] = '\0'; strncat(target, source, sizeof target); does what most people probably assume strncpy should do (assuming target is defined as an array rather than as a pointer).
I would understand if you said that strncat is broken (since it can output non \0 terminated strings, unlike the non-standard strlcat, breaking the principle of least astonishment) but I fail to see the problem here.
Quote examples
The most salient quote from Daniel Micay (strncat): "It doesn't demonstate a pattern you would use in Rust.
In this case, a automated system rejecting anything that uses the non "n"(strcat vs strncat, etc.) version of the string functions in C would have worked.
It would be like shipping a C standard library with "strcat" but not "strncat".
Frequently asked questions
Short answers drawn from the clearest meanings and examples for this word.
How do you use strncat in a sentence?
The problem is that people have religious wars about strncat vs strlcat, which are both terrible and both equally broken, rather than looking at the big picture.