News for hackers. Stuff that matters.
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.
Re:Beware of strncpy and strncat by tinus_hn on Wednesday June 06, 2018 @04:01PM (#17250568)
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’.