Hi
I found out that the following piece of code throws an error.
1 #include "stdio.h"
2
3 int main()
4 {
5 int a,b;
6 a= 10;
7 a>10?b=20:b=30;
8 printf("%d",b);
9 }
and the error was:
$ gcc -g -o test test.c
test.c: In function `main':
test.c:7: error: invalid lvalue in assignment
However, when you rewrite line 7 as:
a>10?b=20:(b=30);
Then there is no error. Why it is so? I thought conditional operators where
an macro-like replacement of a simple if-else statement.
Is there any other such odd things (not behavior) in using a conditional
operator I need to be aware of?
For that matter, is there any website that would point to such quirks in c?
Any help would be greatly appreciated.
Regards,
Muralidhar
mu********************@yahoo.com