How to memset an array of bools?

前端 未结 6 1813
心在旅途
心在旅途 2021-02-20 13:25
void *memset(void *dest, int c, size_t count)

The 3rd argument is the Number of characters or bytes in the array. How would you memset an array of bool

6条回答
  •  一生所求
    2021-02-20 14:00

    memset sets memory in multiples of bytes. So, the only way is to add padding to your bool pointer such that its length is a multiple of 8. Then do memset. Personally I would prefer if there were any other alternative than putting a redundant padding. But I haven't found any alternative solution to date.

提交回复
热议问题