+ 1
Can anyone help me out please?
#include <stdio.h> typedef struct { int bit1:1 ; int bit2:2; int bit30:30; }bits; int main() { printf("%d",sizeof(bits)); return 0; }
2 Réponses
+ 7
What's your question, why the output is 8? An integer usually has four bytes = 32 bits. You're using one bit of the first int for bit1 and two more bits for bit2. There's 29 bits remaining, but bit3 takes 30 bits. So you need two integers to store all (1+2+30=) 33 bits. Two integers = 2*4 bytes = 8 bytes
+ 1
How