I have a bit of code in C++ that writes structs to a file. The format of the struct is:
struct dataHeader
{
int headerID;
int numberOfDataLines;
};
struct data
{
double id;
double type;
char[100] name;
char[100] yyy;
};
Now, these two structs are always written in pairs and a file contains upwards of 50000 of these pairs.
My question is is there a way to do this more efficiently? The file size is a major concern to me.
EDIT: The current code is a simple fwrite in a loop (Psuedo-code) :
while(dataBlock.Next())
{
fwrite(&_dataHeader, sizeof(dataHeader), 1, fpbinary);
while( dataLine.Next())
{
fwrite(&_data[i], sizeof(data), 1, fpbinary);
}
}
Thanks.