avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Understanding Problem or Error with ++ Operator


From: Julius Luukko
Subject: Re: [avr-gcc-list] Understanding Problem or Error with ++ Operator
Date: Fri, 8 Aug 2003 15:32:00 +0300
User-agent: KMail/1.4.3

On Friday 08 August 2003 15:14, Dirk Hoffmann wrote:
> Hi folks,
> I have a problem like this:
> This code is working, as i expect, it adds one to CurSektor,
> void FAT_NextSektor ( unsigned long *CurCluster, unsigned long *CurSektor )
> {
>       [...]
>       *CurSektor= *CurSektor+1;
>       [...]
> }
> But I wrote it before as:
> void FAT_NextSektor ( unsigned long *CurCluster, unsigned long *CurSektor )
> {
>       [...]
>       *CurSektor++;
>       [...]
> }
> This increments the pointer SurSektor by 4.
> The same compiler output as CurSektor++;

That's how it's supposed to work. Write 

(*CurSektor)++

instead. Increment and decrement operators act from right to left.

-- 
D.Sc. Julius Luukko
Laboratory of Control Engineering/Department of Electrical Engineering
Lappeenranta University of Technology, FINLAND
phone:+358-5-621 6713, fax:+358-5-621 6799, www: http://www.ee.lut.fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]