Initializing Primitive Array to One Value

前端 未结 6 1327
暗喜
暗喜 2021-01-18 03:55

Is there a way to initialize an array of primitives, say a integer array, to 0? Without using a for loop? Looking for concise code that doesn\'t involve a for loop.

6条回答
  •  被撕碎了的回忆
    2021-01-18 04:29

    You can use memset if you want all your values to be zero. Also, if you're only looking to initialize to zero, you can declare your array in such a way that it is placed in the ZI section of memory.

提交回复
热议问题