From a39951d8f69209cfea2b7051832b851914e662ef Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 22 Feb 2020 09:56:09 +0000 Subject: now version controlled. --- structcmp.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 structcmp.c (limited to 'structcmp.c') diff --git a/structcmp.c b/structcmp.c new file mode 100644 index 0000000..c1f28c1 --- /dev/null +++ b/structcmp.c @@ -0,0 +1,32 @@ +#include +#include + +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); +} -- cgit v1.2.3