接收short,将其分成两个char写入文件
void WriteU16(std::ostream& file, short val) { char bytes[2]; // extract the individual bytes from our value bytes[0] = (val) & 0xFF; // low byte bytes[1] = (val >> 8) & 0xFF; // high byte // write those bytes to the file file.write((char*)bytes, 2); }