how would be the input to make following if condition false if ((gr->parent &&…
- User
how would be the input to make following if condition false if ((gr->parent && !gr->parent->overlay_enabled) || (gr->parent && gr->parent->overlay_enabled && !gr->overlay_enabled)) { return; }
- Assistant
To make the if condition false, you must ensure that none of its conditions are met. Let's break down the if condition to understand it better:
-
(gr->parent && !gr->parent->overlay_enabled): This part is true ifgr->parentis not NULL (gr->parentexists) andgr->parent->overlay_enabledis false. -
(gr->parent && gr->parent->overlay_enabled && !gr->overlay_enabled): This part is true ifgr->parentis not NULL (gr->parentexists),gr->parent->overlay_enabledis true, andgr->overlay_enabledis false.
For the if condition to be false, both parts need to be false. Therefore, consider the following scenarios for the
grstructure and itsparent: -
- User
is this input correct ? gr.parent->overlay_enabled = 0; gr.parent = &gr1; What changes I have to made the if fails
- Assistant
To make your example work as intended for the condition to fail, you need to correct the order of your statements and ensure they meet one of the correct scenarios. According to the given if condition, you want the entire condition to evaluate to false.
Based on your input:
cgr.parent->overlay_enabled = 0; gr.parent = &gr1;