My file needs to be updated frequently, meaning that new data has to be appended, but in a very specific way. The following is the sample content of my "file.txt" (2 vectors of length 6):
1 2
3 4
5 6
7 8
3 4
5 6
After certain calculations, new vectors need to be appended to this file. Suppose v={9, 8, 7, 6 , 5, 4} is the vector to be added. The file content should be:
1 2 9
3 4 8
5 6 7
7 8 6
3 4 5
5 6 4
Note that simple rewriting the file based on old+new vectors is not an option, and the vectors need to be 'appended' as I did. The idea is to reach the end of each line, and start appending there, then jump to next intact line, do the same thing...
This is what I've tried, but it doest work:
std::fstream out;
out.open("file.txt", std::ios::in | std::ios::out);
std::string myHelper;
getline(out, myHelper);
out<<9<<std::endl;
Any suggestions? Thanks