#include <stdint.h> #include <string.h> #include <endian.h> void uint16_store(unsigned char *s,uint16_t x) { x = htole16(x); memcpy(s,&x,sizeof x); }