Reading and writing a std::vector into a file correctly
That is the point. How to write and read binary files with std::vector inside them? I was thinking something like: //============ WRITING A VECTOR INTO A FILE ================ const int DIM = 6; int array[DIM] = {1,2,3,4,5,6}; std::vector<int> myVector(array, array + DIM); ofstream FILE(Path, ios::out | ofstream::binary); FILE.write(reinterpret_cast<const char *>(&myVector), sizeof(vector) * 6); //=========================================================== But I don't know how to read this vector. Because I thought that the following was correctly but it isn't: ifstream FILE(Path, ios::in |