|
From: | Nils Springob |
Subject: | Re: [avr-gcc-list] OT Generic C question |
Date: | Tue, 20 Sep 2005 16:08:01 +0200 |
User-agent: | Mozilla Thunderbird 1.0.2 (X11/20050317) |
Hi,In C the result of this expression is undefined. The C language defines that the compiler is allowed to increment the variable i before or after the assignment operation.
h=i++ is valid C, h will have the old value of i, i will be incremented.i=i++ is invalid C, the value of the variable i will be i or i+1 after execution of this expression, depending on the compiler.
Regards, Nils
int i; i=0; i=i++;//i was still zero thatThat is i=i++ never incremented i, now I would have thought the line would be the same as: i=i;i=i+1;
[Prev in Thread] | Current Thread | [Next in Thread] |