Created
November 14, 2019 11:35
-
-
Save fxff/3ce7c312cc7aaa9ee5888d100148752f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct { | |
int foo; | |
int bar; | |
} A; | |
typedef struct { | |
char foo; | |
char bar; | |
} B; | |
typedef union | |
{ | |
int type; | |
A a; | |
B b; | |
} Returnable; | |
Returnable func (void) | |
{ | |
Returnable r; | |
r.a.foo = 200; | |
r.a.bar = 300; | |
r.type = 100; | |
return r; | |
} | |
int main (void) | |
{ | |
Returnable r = func(); | |
printf("%i\n", r.a.foo); | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment