summaryrefslogtreecommitdiff
path: root/structcmp.c
blob: c1f28c14890a2fe1fd9e85d88ed9d53458d170bf (plain)
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
#include <u.h>
#include <libc.h>

enum {
	A = 1,
	B = 2,
	C = 4,
	D = 8
};

typedef struct Fruit Fruit;
struct Fruit {
	char *name;
	int vitamins;
};

void
main()
{
	Fruit apple, lemon, apple2;

	apple = (Fruit){"apple", C};
	lemon = (Fruit){"lemon", B|C};
	apple2 = (Fruit){"apple", C};
	if(apple == apple)
		fprint(2, "apple equals apple\n");
	if(apple == apple2)
		fprint(2, "apple equals apple2\n");
	if(apple == lemon)
		fprint(2, "apple equals lemon, really?\n");
	exits(0);
}