Can you have an increment and decrement in the same variable in the same expression in c

there is

--foo++;

valid operator in C? (Will it compile / run) And is there any practical application for this?

Sorry to edit the question in the edit, but I found something.

According to my C ++ compiler (Visual Studio 2010):

--++foo;

is a valid team but

foo--++; 

no. Is there a reason for this?

+1
source share
2 answers

No, this is not true, because the result of increment / decment statements is not an lvalue.

EDIT: OP edited his question by adding two more examples. So, let's go for the same reason:

--++foo;
--foo++;
foo--++;

- , increment/decment lvalue. , - .

+8

C, , .

- ++ Foo;

ok : -

++ Foo;

,

, pre increment foo foo + 1.

foo = foo + 1;

foo ( , ).

- (++ Foo);

- ( );// foo + 1

,

value = constant_valu + 1;// ,

.

-d So lvalue

0

All Articles