DIY sysex fader box status and questions. - Pointers

ToAd tom.adam at thebigear.be
Sat May 5 16:14:25 CEST 2012


OK pointers...
I'm reading " Emdebbed C programming and the atmerl AVR " by Barnett, 
Cox and O'Cull.

I understand this:
char *p;
char a,b;
p=&a; //p equals the address of a
b=*p;  // b equals the value pointed to by p
result: b=a
and this:
char *p;
char a,b;
p=&a;
*p=b;  //the location pointed to by p is set to the value of b
result: a=b

OK, now this:
char c;
char *p;

c = *p++;
assign c the value pointed to by p, and then increment the address of p.
What address? I don't know the address! What values is there? Since it's 
a machine address I'm guessing it's the char "next to it", but how do I 
know what is "next to it"?

c=*++p;
increment the address p, then assign c the value pointed to by p.
Idem

c=++*p;
increment the value pointed to by p, then assign it to c. So p is not 
changing here, this one I understand ;-)

c=(*p)++;
assign c the value pointed to by p, then increment the value pointed to 
by p, leaving p untouched.
so the value pointed to by p is changed, so if i ask for *p in my 
program again, the retuned value will have changed. This looks interesting.

Any help appreciated.

ToAd


More information about the music-bar mailing list