Re:Beware of strncpy and strncat
by hxchen on Wednesday June 06, 2018 @03:36PM
(#17250338)
Or use calloc. It does the same thing as malloc, but init memory to zero automatically.
[ Parent
| on HN ]
If you’re going to allocate the memory you might as well just use the library functions that allocate exactly the space you need and copy the string into it. These tricks are for when you use the stack as an ‘optimization’.