3 ms·
Or use calloc. It does the same thing as malloc, but init memory to zero automatically.
by hxchen 8y ago
Or use calloc. It does the same thing as malloc, but init memory to zero automatically.
- tinus_hn 8y agoIf 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’.