0

Whats does the : symbol means in c structure. The code below supposed to show output 12 (size of int=4,size of structure=sum of each structure member)

But it is showing 8 as output.

#include<stdio.h>

typedef struct
{
int bit1:20;
int bit2:1;
int bit30:30;
} bits;

int main()
{
printf("%d",sizeof(bits));
}

But when i change the value

int bits30:30;

Into

int bits30:40;

It is showing an error,what is the use of : in c structure.

Dora
  • 3
  • 4

0 Answers0