OR operator in loops?

Whenever I seem to use || it just glitches up the program, and if either variable is true, it will keep looping.

As in

1
2
3
4
while(Bool1==false || Bool2==false)
{
Bool1=true;
}


Am I not supposed to be using an or for this?
I was meaning for it to be as if even one of the variables are true, and not false, it will break the loop.
If Bool2 is false it will loop forever, as you don't change Bool2 inside of the loop.
I thought && is supposed to make it where both need to be true? I'm confused.
Okay, somehow I got those mixed up, I guess I am trying to read things into English to much. :/
if you want it to loop when they are both false, and break when at least one is true

while ( Bool1 == false && Bool2 == false )

I think your confusion is coming from the fact that you're using a while loop and not an if statement, the condition in the brackets is what you want to be true in order to go into the loop, not when to break out of the loop

Last edited on
Topic archived. No new replies allowed.