#include <stdio.h>
int main(void){
int n = 0, y = 1;
y == 1 ? n = 0 : n = 1;
if (n)
printf("YES");
else
printf("NO");
return 0;
}
Can some one explain why does the line with the ternary operator give a lvalue error. I have a very abstract idea of what lvalue is. Let me give my abstraction, correct me if I am wrong. lvalue is typically the address or we can say the variable where we store a constant value and the value of a variable or a constant is a rvalue. But I don't understand why is there an lvalue error in the assignment part of the ternary operator which states n = 0 : n = 1. It would be really helpful if I could get a proper understanding of what is wrong with my code.