Hello,
I would like to ask you if you can help me with the following coding.
The first thing is to have the data below which may have random number of rows and columns.
The example of the data is here (7 rows, 6 columns, tab delimiter):
The first of all I have the data in the vector:
vector< vector<float> > items;
Now I need to write them to the binary file correctly.
Then I need to read them from the binary file and have them in the vector again and they should be in in the way that it shown above (7 rows, 6 columns...but these numbers may vary from case to case).
I hope that everything is clear.
Thank you very much in advance.
Think about how you would read and write a std::vector<float> item to/from a binary file. First write an integer value specifying the item.size() of the vector. The follow that with the contents of the vector, that can be done in a single write().
Reading from the file is the reverse, read the integer - check that the read succeeded. Then resize or allocate a vector with that size and read directly from the file to the vector data area. Possibly use something like &item[0] to get the start of the data when reading or writing.