Hi,
Thats a great idea. If I understand you correctly, then this shouldn't be too hard. Using the [b:7a32f5d626]sizeof[/b:7a32f5d626] operator, you will know exactly how big a binary variable is, and therefore where in a file any particular item will be into that file.
Something like (sorry I'm used to the C style for files!)
template <class T> class binaryio { FILE* stream; binaryio(char* filename) { stream = fopen(filename, "b"); } T operator [](int i) { fseek(stream, i * sizeof(T), 0); //<- Can't remember the syntax here. T data; fread(&data, 1, sizeof(T), stream); return data; } };
And something smarter to write back to random locations..
Is that what you're think?
Login