Hello again everyone! I have one more question. I have a function here which is not busting out of the while loop when the flag is set to false. Any point in the right direction of where my logic is wrong would be great. Thanks.
num 1 is not a pointer. Why do you check it for null?
what is the input when it fails?
I think it might work if you just put the keyword break in all the false conditions.
do you WANT it to be able to set to true after having set to false, or set to false after having set to true?? As it stands, it can overwrite the flag a few times and then get to the while's test.
what exactly are you trying to do. It looks like some kind of angle checks.
That's my point. You are expecting it to magically break out of the loop even though after that line THERE ARE OTHER LINES OF CODE THAT MAY CHANGE YOUR LITTLE FLAG TO SOMETHING ELSE.
Is that really so hard to understand?
And what about the insane loop?
Wake up!
no, that is not what null is for.
all types have a value all the time. that value may be zero (which is all null is, its a constant that == 0). You can't make something without a value -- as soon as it exists, it has bytes in memory and bytes in memory must have values, as they are actually physical circuits that exist in some state, and every state is a value (some values are invalid, but its still a value that you could force-print in hex).
if this is an overwriting logic that is doing the right thing, its fine.. but we don't really know what you are doing. If its not supposed to overwrite once a value is set, its very wrong. Which way did you intend? Regardless I would rewrite it so that it has a default value (you did that, its true) and then set it to false under some condition. If it needs to go back to true under other conditions, exclude those from setting it false logic.
There is no need to be so critical. For someone that is new to programming it might not be obvious that the loop condition in a do-while loop is only checked at the end of each iteration, and not between each expression.
He does it because he enjoys it. He clearly loves humiliating people, bullying them and making them feel bad. Especially people who are new to coding, and maybe feeling a bit nervous and in need of help - because, after all, people like that are the easiest to bully, right?