From 382d2d431d1f2080d9dae9baadaa00495d903c24 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 9 Mar 2015 13:07:01 +0000 Subject: Minor modifications and new file endianness.c --- endianness.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 endianness.c (limited to 'endianness.c') 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 +#include +#include +#include + +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; +} -- cgit v1.2.3-54-g00ecf