Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
struct jb{
char actor[25];
struct jb *next;
};
struct jb *bond;
int n;
/* Create the first structure in the list */
bond = (struct jb *)malloc(sizeof(struct jb));
printf("struct jb sizeof is %d\n", n = sizeof(struct jb));
printf("struct bond->actor sizeof is %d\n", n = sizeof(bond->actor));
printf("struct bond->next sizeof is %d\n", n = sizeof(bond->next));
/* Fill the structure */
strcpy(bond->actor, "Sean Connery");
bond->next = NULL; /* End of list */
/* Display the results */
printf("The first structure has been created:\n");
printf("\tbond->actor = %s\n", bond->actor);
printf("\tnext structure address = %p\n", bond->next);
return(0);
}
the output:
struct jb sizeof is 32
...
but the array is 25, and pointer is 4, why the struct jb sizeof is not 29?