[Solved] lvalue required as left operand of assignment in conditional operator [duplicate]


It has to do with operator sequencing. What the compiler thinks you’re doing is

(a ? b = 3 : b) = 4

which obviously is incorrect.

Instead, why not put the b on the left side, and get only the value to assign using the conditional expression, like

b = a ? 3 : 4;

solved lvalue required as left operand of assignment in conditional operator [duplicate]