Why does c = ++(a+b) give compilation error?

It’s just a rule, that’s all, and is possibly there to (1) make it easier to write C compilers and (2) nobody has convinced the C standards committee to relax it.

Informally speaking you can only write ++foo if foo can appear on the left hand side of an assignment expression like foo = bar. Since you can’t write a + b = bar, you can’t write ++(a + b) either.

There’s no real reason why a + b couldn’t yield a temporary on which ++ can operate, and the result of that is the value of the expression ++(a + b).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)