I've been dealing with binary files and i was wondaring if there's a way to read data using only unKnown structs.
I'm using that code to deal with binary files:
Code:
struct User{
int a;
}
User IUser_data;
User OUser_data;
fstream username_file("admin.bin",ios::binary|ios::in|ios::out);
OUser.a=1320;
username_file.write((const char *)(&OUser_data),sizeof(User));
username_file.close();
username_file.read(( char *)(&IUser_data),sizeof
(User));
cout<<IUser_data.a<<endl;
if there's a way to load it like this:
Code:
struct User{
}
User IUser_data;
fstream username_file("admin.bin",ios::binary|ios::in);
OUser.a=1320;
username_file.read(( char *)(&IUser_data),sizeof(User));
cout<<IUser_data.a<<endl;
I'll be glad for any comment.