Advertisement
EBobkunov

bitfields

Mar 10th, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. struct date{
  4.     unsigned short int day : 5;
  5.     unsigned short int month : 4;
  6.     unsigned short int year : 7;
  7. };
  8.  
  9. int main() {
  10.     struct date D;
  11. //    printf("Enter day: ");
  12. //    scanf("%d", &D.day);
  13. //    printf("Enter month: ");
  14. //    scanf("%d", &D.month);
  15. //    printf("Enter year: ");
  16. //    scanf("%d", &D.year);
  17.     D.day = 10;
  18.     D.month = 12;
  19.     D.year = 2003;
  20.     printf("Date: %d.%d.%d \n", D.day, D.month, D.year);
  21.     printf("%d", sizeof(D));
  22.     return 0;
  23. }
  24.  
Tags: bitfields
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement