4 ms·
it's an _optional_ part of the standard, and so can't be relied on. also, the idea behind it is pretty poor.
by zabzonk 4y ago
it's an _optional_ part of the standard, and so can't be relied on. also, the idea behind it is pretty poor.
- Night_Thastus 4y agoDon't GCC, Clang and MSVC provide it? It may be optional in practice but if the major compilers support it, it's not really an issue. The idea may not be perfect, but for C which is intended to be low overhead, strcpy_s is about as good as it gets. If you want something more user friendly, that is what C++ is for with std::string, or library implementations like Boost or QT string.
- zabzonk 4y agoMSVC supports it, as it is an MS invention, designed by some intern, i guess. other compilers may or may not, by switches/#defines. it is worthless in any case.
- Night_Thastus 4y ago>as it is an MS invention Source, and why does it matter who made it? >designed by some intern You don't know that, nor is that how standards work. >other compilers may or may not So you've said basically nothing. >it is worthless in any case. It offers a low-overhead, safer alternative to strcpy. Is it perfect? No. But it's one of the better C options for those limited to the standard library.
- zabzonk 4y agoit was put forward to the standards comittee by MS, who have a powerful voice there. no-one else wanted it, which is why it ended up in an annex of the standard. it is badly designed, and does nothing that you can't do yourself, and should be doing yourself, in any well-written code.