I just started learning C Programming and I have a question based on expression evaluation.
If we have 3 variables, a
,b
, and c
:
c=a+++b++;
c=a+++++b;
Why is the 1st expression valid and 2nd invalid?
I just started learning C Programming and I have a question based on expression evaluation.
If we have 3 variables, a
,b
, and c
:
c=a+++b++;
c=a+++++b;
Why is the 1st expression valid and 2nd invalid?
It appears that the C compiler does interpret a+++
as a++ +
, while +++b
generates an error even if you put another variable before it.
In practice it is a very bad idea to write such expressions without spaces. You would confuse yourself when you come back to look at your code, and annoy anyone else looking at it :) Just rewrite:
a++ + b++
a++ + ++b
and everything will work as expected.