c - What is the reason for memsetting initialized buffer -


while traversing wikipedia following links, stumbled across the following code example initializes char buffer 0, memsets 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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -