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

后端 未结 8 2185
你的背包
你的背包 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:13

    In some compilers STRUCT theStruct = {}; would translate to memset( &theStruct, 0, sizeof( STRUCT ) ); in the executable. Some C functions are already linked in to do runtime setup so the compiler have these library functions like memset/memcpy available to use.

提交回复
热议问题