How to memset an array of bools?

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

    //Array declaration
    bool arr[10];
    
    //To initialize all the elements to true
    
    memset(arr,1,sizeof(arr));
    

    Similarly, you can initialize all the elements to false, by replacing 1 with 0.

提交回复
热议问题