Advertisement
EBobkunov

birthDateInTwoBytes

Mar 10th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #define BASE_YEAR 1900
  3. struct date {
  4.     unsigned short day : 5;
  5.     unsigned short month : 4;
  6.     unsigned short year : 7;
  7. };
  8. int main() {
  9.     struct date birthday;
  10.     birthday.day = 14;
  11.     birthday.month = 3;
  12.     birthday.year = 2003 - BASE_YEAR;
  13.     printf("\n My birthday is %u.%u.%u \n", birthday.day, birthday.month, birthday.year + BASE_YEAR);
  14.     printf("\n Size of birthday structure is %lu bytes", sizeof(birthday));
  15.     return 0;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement