struct data
{
std::string s1;
std::string s2;
std::string s3;
long l;
};
int Write(FILE* file, const data* myData)
{
unsigned long length;
length = myData->s1.size();
fwrite((void*) &length, sizeof(length), 1, file);
fwrite((void*) myData->s1.data(), length, 1, file);
... // write the other strings and long here
}
int Read(FILE* file, data* myData)
{
unsigned long length;
char* buffer;
fread((void*) &length, sizeof(length), 1, file);
buffer = new char[length];
length = fread(&buffer, length, 1, file);
myData.s1 = string(buffer, length);
}
Конечно, делайте проверку ошибок, а что нет