Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it. However, I also heard memccpy(3) is even more terrible than strncpy(3). Are these functions really bad? How so?...
#3: Post edited
- I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it.
- However, I also heard memccpy(3) is even more terrible than strncpy(3).
- Are these functions really bad? How so?
- Are there any legitimate uses of any of these functions?
What should we use instead?[I'll reply to myself in a moment.]
- I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it.
- However, I also heard memccpy(3) is even more terrible than strncpy(3).
- Are these functions really bad? How so?
- Are there any legitimate uses of any of these functions?
- What should we use instead?
#2: Post edited
- I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it.
- However, I also heard memccpy(3) is even more terrible than strncpy(3).
- Are these functions really bad? How so?
- Are there any legitimate uses of any of these functions?
What should we use instead?
- I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it.
- However, I also heard memccpy(3) is even more terrible than strncpy(3).
- Are these functions really bad? How so?
- Are there any legitimate uses of any of these functions?
- What should we use instead?
- [I'll reply to myself in a moment.]
#1: Initial revision
Are memccpy(3) or strncpy(3) bad for copying and catenating strings with truncation?
I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it. However, I also heard memccpy(3) is even more terrible than strncpy(3). Are these functions really bad? How so? Are there any legitimate uses of any of these functions? What should we use instead?
