MIPI_AdvancedC_FRTK/Lect1/08_page_15.1.c
2024-11-14 08:45:50 +03:00

19 lines
574 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdint.h>
struct date {
uint16_t day : 5; // значение от 0 до 31 unsigned short
uint16_t month : 4; // значение 0 до 15
//~ uint16_t year;//: 7; если огранчить с 2000 до 2127 года
uint16_t year : 7; //если огранчить с 2000 до 2127 года
};
int main(void)
{
//~ struct date dt = { 31, 12, 2021 };//{ 31, 12, 21 }
struct date dt = { 31, 12, 127 };
printf("Size is %llu\n", sizeof(dt));
printf("Date is %u/%u/%u\n",dt.day, dt.month, dt.year);
//+2000);
return 0;
}