How to memset an array of bools?

前端 未结 6 1748
心在旅途
心在旅途 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:16

    To set array of 11 bool elements to e.g. true by using memset:

    const int N = 11;
    bool arr[N];
    memset(arr, 1, sizeof(bool) * N);
    

提交回复
热议问题