[sdiy] Pointers in C

Paul Maddox yo at vacoloco.net
Sat Dec 31 12:42:41 CET 2011


All,

  Pointers have always confused me, though I'm getting better slowly.

  But I have a question, if I have a pointer to an unsigned long int (32bits) and I want to access it as four unsigned chars, do I just read a char and increase the pointer? for example;

int *my_ptr = my_unsigned_long_int;
unsigned char FirstByte = *my_ptr;
my_ptr++;
unsigned char SecondByte = *my_ptr;
my_ptr++;
unsigned char ThirdByte = *my_ptr;
my_ptr++;
unsigned char FourthByte = *my_ptr;

  or am I nuts?

Paul

______________________________________
VacoLoco

http://VacoLoco.net







More information about the Synth-diy mailing list