How do I set each element in a boolean array to false?

closed account (oN3h0pDG)
Sorry for this beginner question, It's very late here so my head may not be on so straight right now. Anyways, I have a boolean array of 365 and I need to make a loop to set each array element to false, so that I have 365 elements equal to false. Not sure how to do it. Would I use a for loop? and how would I do it?

Thanks for the help!

 
bool bdays[365];
1
2
for (auto& value : bdays)
  value = false;
Or:

1
2
3
4

for (int i = 0; i < 365; i++)
  bdays[i] = false;
closed account (E0p9LyTq)
Much easier:

bool bdays[365] = { false };

An initializer list works wonders.

1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main()
{
   bool bDays[365] = { false };

   std::cout << std::boolalpha << bDays[364] << std::endl;

   return 0;
}
Topic archived. No new replies allowed.