c++ - C programming unary operator precedence -
this question has answer here:
#include <stdio.h> int main() { int c=10,b; b=++c+++c; printf("%d",b); return 0; }
could please let me know,why throwing compilation error?
the gibberish tokenised as
++ c ++ + c
and parsed as
((++c)++) + c
this tries increment rvalue yielded ++c
, isn't allowed. can increment lvalue (or class type, in c++).
even if allowed, give undefined behaviour: you'd have unsequenced modification , use of value of c
.
Comments
Post a Comment