1 /* 2 * typedef.c 3 * 4 * Beispiel-Programm typedef 5 * 6 * Autor: H.Drachenfels 7 * Erstellt am: 25.2.2015 / 10.11.2017 (C11) 8 */
9
10 #include <stdio.h>
11
12 struct date
13 {
14 int day;
15 const char *month;
16 int year;
17 };
18
19 typedef struct date date;
20
21 int main(void)
22 {
23 date d = {1, "September", 2000}; // statt struct date
24
25 //--------------------------------------------- print variable value
26 printf("%d. %s %d\n", d.day, d.month, d.year);
27
28 //------------------------------------------- print variable address
29 printf("&d = %p\n", (void*) &d);
30 printf("&d.day = %p\n", (void*) &d.day);
31 printf("&d.month = %p\n", (void*) &d.month);
32 printf("&d.year = %p\n", (void*) &d.year);
33
34 //---------------------------------------------- print variable size
35 printf("sizeof d = %zu\n", sizeof d);
36
37 return 0;
38 }
39