Using reinterpret_cast to read file into structure
问题 struct DATAs { char data1; short data2; short data3; float data4; int data5; short data6; unsigned short data7; short data8; char data9; }; void fixFile(char* filename) { std::ifstream InputFile; InputFile.open(filename, std::ios::binary); DATAs FileDatas; InputFile.read(reinterpret_cast<char*>(&FileDatas), sizeof(FileDatas)); } Why do I need to use "reinterpret_cast" for the reading instead of "InputFile.read(&FileDatas, sizeof(FileDatas))" ? 回答1: The type of the first argument to std: