I am have one question. Lets say we have a struct which is defined as follows:
typedef struct test {
int x;
int y;
};
Now if I create a instance of this struct as follows;
test object;
So will the " &object == &object.x "??
I am have one question. Lets say we have a struct which is defined as follows:
typedef struct test {
int x;
int y;
};
Now if I create a instance of this struct as follows;
test object;
So will the " &object == &object.x "??
Yes the address of the first data member of the structure will be equal to the address of the object of the structure itself.
From the C Standard (6.7.2.1 Structure and union specifiers)
15 Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared. A pointer to a structure object, suitably converted, points to its initial member (or if that member is a bit-field, then to the unit in which it resides), and vice versa. There may be unnamed padding within a structure object, but not at its beginning.