简体   繁体   中英

Conditional operator and assignment operator in C

On http://groups.google.co.in/group/comp.lang.c/browse_thread/thread/bfb312ad902d94eb/74dcdcacce777679?lnk=gst&q=conditional+operator#74dcdcacce777679

There is an answer given for a question why
(A%2==0)?A=0:A=1 gives error.

The thing I don't understand that when do we use (precedence and associativty) and we
use C grammar to parse the expression ?

Always use the grammar to parse expressions.

Precedence and associativity are derived from the grammar, they are not the rules. Many precedence tables are over-simplifications that don't work in some obscure corner cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM