4 ms·
Strcpy: A niche function you don't need. (2021)
- theamk 3y agoAgree about strdup(), but as the author says, it's a performance issue, not a correctness one. As for static strings... I think it'd be pretty hard to convince people that strcpy(err->message, "out of memory"); is somehow much worse than static const char oom[] = "out of memory"; static_assert(sizeof(err->message) >= sizeof(oom)); memcpy(err->message, oom, sizeof(oom)); especially if "err->message" is very long. (That said, I personally prefer to use asprintf/snprintf even for static strings, for consistency's sake)