In C, it\'s legal to write something like:
int foo = +4;
However, as far as I can tell, the unary plus (+) in +4
I found two things that unary + operator do is
integer promotionturning lvalue into rvalueinteger promotion example:
#include
int main(void) {
char ch;
short sh;
int i;
long l;
printf("%d %d %d %d\n",sizeof(ch),sizeof(sh),sizeof(i),sizeof(l));
printf("%d %d %d %d\n",sizeof(+ch),sizeof(+sh),sizeof(+i),sizeof(+l));
return 0;
}
Typical output (on 64-bit platform):
1 2 4 8
4 4 4 8
turning lvalue into rvalue example:
int i=0,j;
j=(+i)++; // error lvalue required