I might posted the same message to the wrong forun, so I c&p the
message help to ask help. Sorry for the dup.
I am using Dev-C++ Version 4.9.9.2.
I am confused by the results from compiling the following two statements:
(A) x = 0 ? 2+5 : x=y;
(B) x = 1? 2+5 : x=y;
The variables x and y are declared as int and initialized.
For (A), there is no error message from compiling and executing.
However, for (B), the compiler showed the error message:
invalid lvalue in assignment.
I figured out that the compiler located the error at "x=y". But I
could not find any explanation for this.
Can anyone help? Thanks in advance.
--
JC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I might posted the same message to the wrong forun, so I c&p the
message help to ask help. Sorry for the dup.
I am using Dev-C++ Version 4.9.9.2.
I am confused by the results from compiling the following two statements:
(A) x = 0 ? 2+5 : x=y;
(B) x = 1? 2+5 : x=y;
The variables x and y are declared as int and initialized.
For (A), there is no error message from compiling and executing.
However, for (B), the compiler showed the error message:
invalid lvalue in assignment.
I figured out that the compiler located the error at "x=y". But I
could not find any explanation for this.
Can anyone help? Thanks in advance.
--
JC
I recommend that you post your question to an active forum:
http://cboard.cprogramming.com/
(A) x = 0 ? 2+5 : x=y;
(B) x = 1? 2+5 : x=y;
Try (B) x=1? x=2+5 : x=y; // add x = 2 + 5