//The bitwise operators abstract away the endianness. //For example, the >> operator always shifts the bits towards the least significant digit. #include #include int main(void) { FILE *f1 = fopen("test1", "w"); FILE *f2 = fopen("test2", "w"); uint16_t x = 0xABCD; fwrite(&x, 2, 1, f1); uint8_t low_byte = x & 0xFF; uint8_t high_byte = x >> 8; fputc(low_byte, f2); fputc(high_byte, f2); fclose(f1); fclose(f2); return 0; }