05-26-2012, 01:07 PM
In C++ its even more cool, u can read a struct from a file without having to read the members seperate
The problem with streaming a c++ struct to a file/network/database is that it only works on fix size struct but on dynamic size structs will not work correctly(you would need to create a method to stream each members)
this struct will work 2 bytes to id and 12 to name
struct data{
int id;
char name[12];
};
//this struct will not work 2 bytes to id and 4 bytes is the pointer address in memory.
struct data{
int id;
char* name;
}

