1. ## simple array question

Given :
Code:
`char RXData[20] = { [ 0 ... 19 ] = 0xFF }, *rxMssg;`
Why is the following incorrect?

Code:
`rxMssg = &RXData;`
I understand that
Code:
`rxMssg = RXData;`
and
Code:
`rxMssg = &RXData[0];`
work.....I just don't quite get why &RXData does not work

2. Because &RXData is a pointer to the whole array, whereas RXData and &RXData[0] are pointers to the first element of the array.

Write char (*rxMssg)[20] = &RXData;
if you want to point to the whole array.

Compare with
Code:
```struct foo {
int bar;
};

struct foo var;
struct foo *p = &var;
int *q = &var.bar;```
p and q point to the same address, but the types are different.

3. I am not sure I understand.....How can an address point to "the whole array"?....An address points to a single location... Your comment seems to imply that all 20 elements of the array can be pointed to by one address

4. Yes, and that's the location of the array.

After all, an address doesn't "point" to anything. It's just a number used to conceptually label some byte in memory. A pointer, on the other hand, conceptually points to some object by having both the address of the starting byte of that object, as well as having a type from which the number of bytes occupied by that object can be derived (and hence the "stride" in the sense of how many bytes are skipped when incrementing the pointer).

Consequently, a pointer can point to an element of an array, and another pointer of a different type can point to the entire array, even though the numeric address assiciated with both of them are the same.

5. But isn't the address of an array defined by it's 0th element? I understand an address is a 'placeholder'. I also understand that the right hand side of a pointer is an address. In my expressions window if I put in array....I get 0x2020 and all the values. This 0x2020 is the element of the 0th element. If I put in to the expressions window &array I get the same thing.

Can you supply an example to show me ?

6. That's right. Hence you need to look at the type of the pointer, not just the numeric address associated with it.

Given an array x of 10 ints, x is converted to a pointer to the int object at index 0, so this pointer is of type int* and is equivalent to &x[0]. But x itself is of type int[10], so &x is a pointer to the entire array, i.e., int (*)[10]. This is basically what Salem told you in post #2.

If it helps, think about what happens when you have an array of arrays.

7. Thank you....That last line really helped!!!