Mark Stokes wrote:

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
to:

Unsigned char ReadByte( unsigned int *address )
{
unsigned char data;

   // Setup read from memory chip (SPI)

   E2DISABLE;      // End Read operation
   // Auto increment address the proper number of bytes
   *address++;
   return data;
}

I expected the contents of memory that address pointed to be incremented
one.

You're new to C, aren't you? That's not a put down, but a simple observation. Look in almost any substantial C program, and you will find lots of:

   char *s;
   char buf[1000];

   s - buf;
   while (*s)
       do_something(*s++);

kind of code, working through the characters of a string. As others pointed out, it is the presedence rules that makes this predictably step through the characters in the string, and not bump the value of the character itself.

*s++ it the quintisential C expression :-)

Regards,
Steve



Reply via email to