NetBSD-Docs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: strcpy(3) examples use of sizeof



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


Home | Main Index | Thread Index | Old Index