I being wondering the tokens and how they are evaluated by the compiler, But I never considered space as a essential token for making a statement valid syntactically,
For example.
#include<stdio.h>
int main(){
int first=1,second=3;
int res=first+++++second;
printf("%d \n",res);
return 0;
}
Gives the following error:
rough3.c:7:17: error: lvalue required as increment operand int res=first+++++second;
But by simply appending a " " between two postfix (++) and prefix (++) seems to work fine.
#include<stdio.h>
int main(){
int first=1,second=3;
int res=first++ + ++second;
printf("%d \n",res);
return 0;
}
Works fine prints value 5.
I have looked into this question rather then undefined behavior I want to know :
When does compiler decides that spaces between expression are redundant or not?
What happens when we take precedence and associativity together to evaluate these expressions?