if statement - In C whether the second part of if structure is executed if first logical part failed? Is the behavior compiler depended? -
extending question what happens if first part of if-structure false?
for c programming
if((null!=b)&&(query(&b)))
in above code part "query(&b)" executed if b=null? , behavior consistent across compilers?
no, logical operators in c short-circuit.
if attempt evaluate a && b
when a
false, b
not evaluated.
but keep in mind you're not checking b
original statement, rather you're checking a
. note it's safe take address of variable that's null, can't dereference it.
i suspect should writing is:
if ((b != null) && (query (*b)) ...
Comments
Post a Comment