git.samba.org
/
tridge
/
junkcode.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
fixes for Power64
[tridge/junkcode.git]
/
tunion.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
4
struct parm_struct
5
{
6
char *label;
7
union {
8
int b;
9
int i;
10
char *s;
11
char c;
12
} u;
13
};
14
15
16
static struct parm_struct p[] =
17
{
18
{"int", {i:42}},
19
{"bool", {b:1}},
20
{"string", {s:"foobar"}},
21
{"char", {c:'t'}},
22
{NULL}};
23
24
int main()
25
{
26
printf("%d\n", p[0].u.i);
27
printf("%d\n", p[1].u.b);
28
printf("%s\n", p[2].u.s);
29
printf("%c\n", p[3].u.c);
30
return 0;
31
}