aboutsummaryrefslogtreecommitdiffstats
path: root/endianness.c
blob: c893be273be281d4a27a0916638d9ac9c7a6edbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}