Lurker News
Back to discussion

Comment by dhsysusbsjsi

dhsysusbsjsi2 replies#
That’s what strncpy() is for
saagarjha1 reply#
Watch out: what strncpy does is usually not what you'd want it to do.
shawxe1 reply#
That's what strlcpy() is for.
saagarjha#
Or strncpy, if you'd like to stay within the standard and your strings are small.
jjnoakes#
No, it's not. strcpy is fine to use if the destination buffer is larger than you need or uninitialized. That's idiomatic...