P
Phui Hock
Hi,
I'm a newbie in C. Can anyone tell me why the size of 'test' is 8
bytes instead of 4 bytes when I uncomment the 'struct list *next;'? I
hope someone can can explain to me. I can't find answer anywhere in my
references nor on the net. Thank you very much.
#include <stdint.h>
typedef struct list{
uint8_t a :6;
uint8_t b :1;
uint8_t c :1;
struct {
uint8_t x :4;
uint8_t y :1;
uint8_t z :3;
} inner;
/* struct list *next; */
} test;
int main(){
printf("size of test is %d\n", sizeof(test));
return 0;
}
I'm a newbie in C. Can anyone tell me why the size of 'test' is 8
bytes instead of 4 bytes when I uncomment the 'struct list *next;'? I
hope someone can can explain to me. I can't find answer anywhere in my
references nor on the net. Thank you very much.
#include <stdint.h>
typedef struct list{
uint8_t a :6;
uint8_t b :1;
uint8_t c :1;
struct {
uint8_t x :4;
uint8_t y :1;
uint8_t z :3;
} inner;
/* struct list *next; */
} test;
int main(){
printf("size of test is %d\n", sizeof(test));
return 0;
}