I have very simple but huge vectors:
struct Vectors //of the same types and the same sizes
{
vector<int> A;
vector<int> B;
vector<int> C;
vector<int> D;
vector<int> E;
vector<int> F;
}
and want to write them to a binary file in one shot.
So far I successfully wrote and read a single vector to a binary file with the help of: file.write(reinterpret_cast<const char*>(&A[0]), sizeof(A));, file.read(reinterpret_cast<char*>(&A[0]), sizeof(binaryfile));
I did the same thing for these 6 vectors one after another, but when I try to read the binary file, there is an error: vector subscript out of range
Could the issue be with the automatic padding? And how to overcome it? Is it possible to write and then read the whole struct of vectors in one shot? So that it is readily available after I memory mmap the binary file? By the way, I do not insist on using vectors, I could use arrays or whatever data type is better for my case...
Aucun commentaire:
Enregistrer un commentaire