1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| #include <stdio.h> #include <stdlib.h>
#define NAMESIZE 32
struct { int i; char ch; float f; } a = { 1, 'a', }, b, c, *p, *q;
struct simp_st { int i; char ch; float f; };
struct student_st { int id; char name[NAMESIZE]; struct birthday_st { int year; int month; int day; } birth; int math; int chinese; };
void func(struct simp_st *b) { printf("%d\n", sizeof(b)); }
int main() {
struct simp_st a; struct simp_st *p = &a;
func(p);
#if 0 struct student_st stu = {10011, "Alan", {2011, 11, 11}, 98, 97}; struct student_st *p = &stu; struct student_st arr[2] = {{.name = "Alan"}, {.name = "John"}};
p = &arr[0];
for (int i = 0; i < 2; i++, p++) { printf("%s ", p->name); } printf("\n");
#endif
#if 0 struct simp_st a = {123, 456.789, 'a'}; a.i = 112233; printf("%d %f %c", a.i, a.f, a.ch); #endif
exit(0); }
|