Do you have a question? Post it now! No Registration Necessary
- Tauno Voipio
July 4, 2003, 2:09 pm
rate this thread
That's OK, just go ahead.
In C, an array name is a constant pointer to the array base address, and an
indexing operation is equivalent to using a pointer constructed as the sum
of the base pointer and index value.
If there is:
arr is a constant char* pointing to the base of the array.
arr[i] is equivalent to *(arr + i)
A word of caution:
The indexing in C takes the size of the array base type into account, so the
byte index into an int array may produce a surprise. In indexing, the
machine byte address is increased by the amount of sizeof(base type)*index.
So, to access a Flash chip residing at 0x01000000:
unsigned char *ptr = (unsigned char *)0x01000000;
ptr is the byte at address 0x01000100.
tauno voipio @ iki fi