aboutsummaryrefslogtreecommitdiffstats
path: root/endianness.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2015-03-09 13:07:01 +0000
committerTomasz Kramkowski <tk@the-tk.com>2015-03-09 13:07:01 +0000
commit382d2d431d1f2080d9dae9baadaa00495d903c24 (patch)
tree552d9153288f9664a040a170beadc0875b8e994b /endianness.c
parentd52c2a2c319ff866906f5072cc5730bf05e4bf35 (diff)
downloadc-stuff-382d2d431d1f2080d9dae9baadaa00495d903c24.tar.gz
c-stuff-382d2d431d1f2080d9dae9baadaa00495d903c24.tar.xz
c-stuff-382d2d431d1f2080d9dae9baadaa00495d903c24.zip
Minor modifications and new file endianness.c
Diffstat (limited to 'endianness.c')
-rw-r--r--endianness.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/endianness.c b/endianness.c
new file mode 100644
index 0000000..c893be2
--- /dev/null
+++ b/endianness.c
@@ -0,0 +1,23 @@
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ bool big_endian;
+
+ union {
+ uint32_t i;
+ char c[4];
+ } test = {0x01020304};
+
+ big_endian = test.c[0] == 1;
+
+ if (big_endian)
+ printf("%s\n", "Big Endian");
+ else
+ printf("%s\n", "Small Endian");
+
+ return EXIT_SUCCESS;
+}