c - What is the reason for memsetting initialized buffer -
while traversing wikipedia following links, stumbled across the following code example initializes char buffer 0, memset
s 0 before use. necessary? if so, why? reason ask no expert, , example states coder's intention comment "/* initialized zeroes */
" on memset
, opposed "/* initialized zeroes */
" on initialization.
edit: note, i've rolled edit on wikipedia page caused this, no longer visible in link.
char buffer[5] = {0}; /* initialized zeroes */ /* declaration / statements, no access buffer object */ memset ( buffer, 0, sizeof buffer); /* initialized zeroes */
in above code, call memset
totally useless. buffer
guaranteed initialized 0
.
Comments
Post a Comment