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
#include <stdio.h> #include <stdlib.h> struct mytype { int c; int d; }; union myunion { int num; char *str; }; typedef struct mytype MyType; int main() { struct mytype v; MyType *v_ptr = &v; union myunion u = {5}; v.c = u.num; v.d = 10; return v.c + v.d; }