memset() or value initialization to zero out a struct?

后端 未结 8 2173
你的背包
你的背包 2020-11-27 10:29

In Win32 API programming it\'s typical to use C structs with multiple fields. Usually only a couple of them have meaningful values and all others have to be zer

8条回答
  •  感情败类
    2020-11-27 11:20

    I would use value initialization because it looks clean and less error prone as you mentioned. I don't see any drawback in doing it.

    You might rely on memset to zero out the struct after it has been used though.

提交回复
热议问题