C
C
Chemodan2282020-02-25 23:39:59
C++ / C#
Chemodan228, 2020-02-25 23:39:59

How is the size of the field bits formed?

#include <stdio.h>
typedef struct {
  int a:1;
  int b:2;
  int c:30;
} fil;
int main() {
    printf("%i", sizeof(fil));
    return 0;
}

Why does the code output 8. If logically 33/8=4. Can you explain please?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-02-25
@TopToster

If logically 33/8=4

If the logic is mathematical, then 33/8 = 4 1/8. And this one-eighth also needs to be stored somewhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question