I have a binary file that I want to read (with fstream) and store in 2 diferent data structures in my program:
the first part, composed of a single line, should be store in a binary tree. Each group of 3 bytes is a node from this tree, and is stored in a
struct.the second part starts after the first's end, and goes to the end of file, and is stored in a single
stringvariable.
this second part I implement this way:
while(!input.eof()) {
char c;
input.get(c);
bitset<8> b(c);
coded_file = coded_file + b.to_string();
}
but I am having trouble figuring out a way to read the first part. My start point is this:
string line;
getline(input, line);
but after that, how I read the string 3 bytes each time, and at same time moving the pointer in a way that when the code for read the second part start to be executed, it starts in the right point.
Anyone have any tips of how to do that?