How to read a binary file to a vector of vector vector structure

I have to read the data from finary file which is in the form std::vector<std::vector<std::vector<sphere_data> >> Sphere_image into std::vector<std::vector<std::vector<sphere_data> >> Sphere_image_read; Could any one help me how this can be read?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 struct ss
{
	int Cno; 
    int c_x;
	int c_y;
   
};
std::vector<std::vector<std::vector<sphere_data> >> Sphere_image ;
std::vector<std::vector<sphere_data>> s_img;
std::vector<sphere_data> s_pixel;
I have written this sphere_image into a binary file like this:

ofstream fout("C:/Project/data.dat", ios::out | ios::binary);
		for (const auto &dim: Sphere_image)
		for (const auto &dim2:dim)
				  fout.write(reinterpret_cast<const char*>(dim2.data()), dim2.size() * sizeof(sphere_data));









std::vector<std::vector<std::vector<sphere_data> > > Sphere_image ;
Can you explain to me why you need a vector that complex?
I have to store data in a matrix where at every position example (0,0) is a vector of structure mentioned
Topic archived. No new replies allowed.