Is it possible to write the equivalent compound "if" statement using the "?" operator in C? I want to write an "if - else if - else" statement and was wonder if I could utilize the "?" operator.
I believe the regular syntax for using "?" would be something like
foo = (bar == 42) ? answerToEverything : useless;
If I wanted to rewrite the following statement in one line using the "?" operator, could I do that? How?
if(bar == 42) {
foo = answerToEverything;
}
else if(bar == 23) {
foo = bigMike;
}
else foo = useless;