why do multiple conditions in the if statement evaluate to false?

I feel like I'm forgetting the basics here, but I can't seem to catch why the statement isn't printing. All 5 conditionals should evaluate to true and the && operator should result, from left to right, they all evaluate to one true. Thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    bool h = true, a = false, d = false, f = false, l = false;
    
    if ((h == true) && (a == false) && (d == false) && (f = false) && (l == false))
        cout << "hello" << endl;

    return 0;
}
Last edited on
Well you have one = where the rest are ==
.......guess its time I go to sleep. Thanks for the tip.
Also, you can simplify your line 10 to just

if (h && !a && !d && !f && !l)
(I realize this might just be a contrived example, but you should avoid having a bunch of one-letter variables.)
Last edited on
Topic archived. No new replies allowed.