I'm very unsure of file IO when it comes to this, and I'm really confused. When I use the insertion stream operator to push some short integers into the file the size of the file is not what I expect:
std::ofstream outFile("myFile.raw", std::ios::binary | std::ios::out);
std::vector<short> list;
for (int i = 0; i < 100; ++i) list.push_back(1);
for (auto i : list) outFile << i;
outFile.close();
This creates a file that is 100 bytes big. I'm not understanding, the short is supposed to be two bytes. The documentation shows that the << operator is overloaded for many different types, so I thought that this writes the correct data type. I guess not.
Thanks.