So far, I have assumed that there is no unary + operator.
But then I came across the following example:
char ch; short sh; int i; printf("%d %d %d",sizeof(ch),sizeof(sh),sizeof(i)); // output: 1 2 4 printf("%d %d %d",sizeof(+ch),sizeof(+sh),sizeof(i)); // output: 4 4 4
Does this mean that + does type conversion here?
Because he behaves the same as
printf("%d %d %d",sizeof((int)ch),sizeof((int)sh),sizeof(i));
This makes me think that + is doing type conversion.
But then I try on double
double f; printf("%d %d",sizeof(+f),sizeof((int)f),sizeof(f));
This makes me rethink the unary + operator.
So, my second question is: does the unary operator + special effect in the sizeof operator?
c sizeof integer-promotion
As Bhullar Jul 17 '14 at 13:56 on 2014-07-17 13:56
source share