The following piece of code:
const int N = 10;
bool can[N];
memset(can, -1, sizeof can);
if(can[0] == 0) { // can[0] == false gives same result
cout << "is zero";
}
else {
cout << "not zero";
}
Outputs is zero
, however I expected it to be not zero
.
Using memset like this instead:
memset(can, 1, sizeof can); // using true instead of 1 gives same result
Outputs not zero
as expected. What is going on?