My C is a little weak, so if I'm off-base here, someone let me know.
Assuming you're talking about the expression *((a) ? &b : &a)
(and that you know how the ternary operator works generally), here's how it breaks down:
The condition (a)
is evaluated: when using an int
in a boolean, 0
evaluates to false, while positive (or non-zero?) values evaluate to true — in this case, a == 0
is false.
The ternary then returns the value &b
if true and &a
if false (in this case it's false, so it returns &a
).
The value thus returned is a reference to a variable; the asterisk before the surrounding parentheses dereferences this reference, so the expression *((a) ? &b : &a)
evaluates to the variable — but not the value of — a
(if a
where not 0
, the expression would evaluate to b
).
That line then assigns to this variable (in this case a
) the value of the second ternary expression, which I assume you can figure out.
The final effect is that it assigns the value of c
to the variable a
, which explains the output.