Re: [algogeeks] C Error

2011-06-24 Thread hary rathor
actually ?: operation have more precedence then = so it evaluate first ,to 10 in next pass it become 10=10 ; which is illegal cause of (=) operator required a variable left side but is present hence error cause lvalue required . -- You received this message because you are subscribed to the

[algogeeks] C Error

2011-06-23 Thread Vishal Thanki
Hey all, I think I am missing something very basic in C, and which is troubling me. Following code is not compiling for me, can anyone explain why? vishal@ubuntu:~/progs/c\ 09:07:01 AM $ cat ternary.c #include stdio.h #include stdlib.h int main(int argc, char *argv[]) { int x =

Re: [algogeeks] C Error

2011-06-23 Thread Wladimir Tavares
Try this: #include stdio.h #include stdlib.h int main(int argc, char *argv[]) { int x = atoi(argv[1]); int y = 10; x = (x 10) ? y++: 10; return x; } Wladimir Araujo Tavares *Federal University of CearĂ¡ * On Fri, Jun 24, 2011 at 12:40 AM, Vishal Thanki

Re: [algogeeks] C Error

2011-06-23 Thread Vishal Thanki
yes, i understand that.. but is there any limitation in ternary operator that the 2nd expression (after :)should not use assignment operator? On Fri, Jun 24, 2011 at 9:21 AM, Wladimir Tavares wladimir...@gmail.com wrote: Try this: #include stdio.h #include stdlib.h int main(int argc, char

Re: [algogeeks] C Error

2011-06-23 Thread Vishal Thanki
Okay, I found the problem i think, (x 10) ? y++: x = 10 is evaluated as ((x 10) ? y++: x) = 10 which is wrong.. (x 10) ? y++: (x = 10) will work. On Fri, Jun 24, 2011 at 9:22 AM, Vishal Thanki vishaltha...@gmail.com wrote: yes, i understand that.. but is there any limitation in ternary

Re: [algogeeks] C Error

2011-06-23 Thread Wladimir Tavares
I was reading in somewhere the ternary operator is *right associative* Wladimir Araujo Tavares *Federal University of CearĂ¡ * On Fri, Jun 24, 2011 at 1:13 AM, Vishal Thanki vishaltha...@gmail.comwrote: Okay, I found the problem i think, (x 10) ? y++: x = 10 is evaluated as ((x 10) ?