Re: strcpy(3) examples use of sizeof

Martin Husemann <[email protected]> Tue, 6 Dec 2022 18:37:13 +0100
Newsgroups gmane.os.netbsd.documentation
Message-ID <[email protected]>
On Tue, Dec 06, 2022 at 12:34:02PM -0500, Jan Schaumann wrote:
> #define NUM 6
> char chararray[NUM];
> (void)strncpy(chararray, "abc", NUM);

That makes the code worse, often the defintion of the buffer and the
strncpy are not next to antother and later changing the size of the
buffer often leads to wrong limits for the strncpy call.

Martin