A library for converting between endianness that doesn't depend on external libraries.
Place conv_endian.c
and conv_endian.h
into your source files
The library can be optionally be built by calling make or using CMake
Downloads
You can download the source code for the library here: https://github.com/Aftersol/convEndian/releases
Examples
Reading big endian data
char yourBuffer[512];
int* ptr_to_buffer = (int*)yourBuffer;
int value;
fread(yourBuffer, sizeof(int), 1, yourfile);
value = *ptr_to_buffer;
value = read_be_u32(value);
Writing big endian data
int value = 1234567890;
value = convert_to_be_u32(value);
fwrite(&value, sizeof(int), 1, yourfile);