I'm trying to teach myself some things about random file I/O with binary, and have come across a task that I am unsure I know how to approach.
Currently I write out a bunch of variable length structs to a binary file. They look something like this
Expand|Select|Wrap|Line Numbers
- struct testStruct
- {
- std::string term;
- unsigned long termCount;
- };
What I want to do is then go through this array and, for want of a better term, extract the actual types and data out of the array. I have tried casting, but that just truncates, and I have tried bit shifts, but I think that I don't understand those well enough to actually make it work.
Can someone suggest a way to do this? Is bit shifting a good approach? Is there something that I haven't mentioned that could be used? It would be much appreciated.
Thanks,
Dylan Jenkinson