Why you are getting lvalue error?
You conditional expression is something like:
flag == 1 ? fp = 1 : fp = 2;
that is parsed in C like:
(flag == 1 ? fp = 1 : fp) = 2;
^ expression = value
and you can't assign a value to an expression that that reason for lvalue error.
The correct answer is given by @Daniel Fischer by adding parenthesis you can rectify your conditional expression(actually overriding precedence).
But interesting this you expression is correct in C++ language!
Read Charles Bailey's answer here: Conditional operator differences between C and C++. You will also find an elaborate answer there why you are getting lvalue error.
(my answer is just a reference to there)
Although @Daniel Fischer and @Joachim Pileborg answer you two tricks you can also achieve same like this:
fd = flag == 1 ? -2 : 3 ;
Yes but this is possible only in your case because you are using fd
in both true/false expression