M
Mark
Hello
I recently encountered this slightly obfiscating code:
void foo(int a)
{
a > 0 && puts("+");
}
seems this is to replace 'if-else' chain as in:
if (a > 0)
printf();
....
But I can't precisely understand the underlying mechanics of '&&' operator
above: 'a > 0' evaluates 1 or 0 depending on the value of 'a', but how does
&& apply to the second operand, which is function ?
I recently encountered this slightly obfiscating code:
void foo(int a)
{
a > 0 && puts("+");
}
seems this is to replace 'if-else' chain as in:
if (a > 0)
printf();
....
But I can't precisely understand the underlying mechanics of '&&' operator
above: 'a > 0' evaluates 1 or 0 depending on the value of 'a', but how does
&& apply to the second operand, which is function ?