summaryrefslogtreecommitdiff
path: root/structcmp.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-02-22 09:56:09 +0000
committerrodri <rgl@antares-labs.eu>2020-02-22 09:56:09 +0000
commita39951d8f69209cfea2b7051832b851914e662ef (patch)
treee4cd1c32e5d6f531b523f6fda558cc3a5f603547 /structcmp.c
downloadbrokentoys-a39951d8f69209cfea2b7051832b851914e662ef.tar.gz
brokentoys-a39951d8f69209cfea2b7051832b851914e662ef.tar.bz2
brokentoys-a39951d8f69209cfea2b7051832b851914e662ef.zip
now version controlled.
Diffstat (limited to 'structcmp.c')
-rw-r--r--structcmp.c32
1 files changed, 32 insertions, 0 deletions
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 <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);
+}