3 ms·
Strlcpy and strlcat are stupid. Strcpy_s and strcat_s for the win :) They have much better error semantics, do the right thing upon failure (set dst[0] to '\0'
by bitwize 13y ago
Strlcpy and strlcat are stupid.
Strcpy_s and strcat_s for the win :) They have much better error semantics, do the right thing upon failure (set dst[0] to '\0' if dst is not NULL and return an error code), and if you are working with C++ in Visual Studio, come with template specializations that can infer the length of the destination string. Which is really handy when the compiler substitutes strcpy and strcat calls with calls to strcpy_s and strcat_s with the appropriate implied length :)
- BudVVeezer 13y agoI am entirely uncertain of why this was downmodded. The _s functions are part of the C standard (Annex K), and truly are better replacements for their counterparts. It's unfortunate that the glibc maintainers have shown so little interest in implementing this (optional, to be fair) part of the standard.
- tobiasu 13y agoBecause the argument why they are "stupid" is missing entirely. Much of the second paragraph was edited in later.