How is a struct
in C sized? For example with the below:
struct Person {
char* name;
char age;
};
int main(int argc, char* argv[]) {
struct Person person1;
person1.name = "John Smith";
person1.age = 40;
printf("The size of the Person object is: %lu.\n", sizeof(person1));
}
This gives me a size of 16
and not 9
. How is a struct
aligned then or is it dependent on the architecture or C implementation? For example, is it on 16-byte boundaries, 8-byte boundaries, etc.?