I expect to see p and &atbl[1] print the same value (location of element 1) but it differs
struct a {
unsigned int el[4];
};
struct a atbl[3] = {
{0x12131415, 0x01030507, 0x01030507, 0x16171819},
{0xa2a3a4a5, 0x02020202, 0x02020202, 0xa6a7a8a9},
{0xb2c3d4e5, 0x02020202, 0x02020202, 0x0badcafe},
};
struct a * p;
// read address of element 1 in atbl
p = (atbl + (1 * sizeof(struct a)));
printf("%08x %08x %08x %08x %08x\n", p, atbl, &atbl[0], &atbl[1], &atbl[2]);
But I get the following results:
p - dae83240
atbl - dae83140
&atbl[0] - dae83140
&atbl[1]- dae83150
&atbl[2] - dae83160
Any hint ?
p = (atbl + (2 * sizeof(struct a)));gets me an out of bounds pointer arithmetic error: 465 bytes (30 elements past end of array.