Damn, it got me again.  I think this exact problem hit me a couple of
months ago.  Precedence stupid!! Heh
Thanks to all!
-Mark


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Daniel
Néri
Sent: Thursday, March 06, 2003 1:51 PM
To: [email protected]
Subject: [Mspgcc-users] Re: Possible problem w/ ++ increment


"Mark Stokes" <[email protected]> writes:

> I've been pulling my hair out about an auto increment problem.  I
> finally realized the following statement wasn't acting as I expected
it

[snip]

>     *address++;

[snip]

> Is this a bug?

No, it's not a bug; ++ has higher precedence than *. That's why you
can do things like

   char *s;
   s = "this is a test";
   while (*s != '\0') putchar(*s++);


So, to get what you want, you could write

    (*address)++;

but IMO, your "fix" looks nicer:

    *address += 1;



Regards,
   --Daniel




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The
debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost
and 
disoriented. TotalView can help you find your way. Available on major
UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


Reply via email to