1 /* 2 * structvar.c 3 * 4 * Beispiel-Programm struct-Variable 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 int main(void)
20 {
21 struct date d = {1, "September", 2000};
22
23 //--------------------------------------------- print variable value
24 printf("%d. %s %d\n", d.day, d.month, d.year);
25
26 //------------------------------------------- print variable address
27 printf("&d = %p\n", (void*) &d);
28 printf("&d.day = %p\n", (void*) &d.day);
29 printf("&d.month = %p\n", (void*) &d.month);
30 printf("&d.year = %p\n", (void*) &d.year);
31
32 //---------------------------------------------- print variable size
33 printf("sizeof d = %zu\n", sizeof d);
34
35 return 0;
36 }
37