Quote Originally Posted by indigo0086 View Post
And I know that in the file the data is sequential and is to be read to the struct in that order, is there a way to read the struct all at once?
Yes, there is a way, pretty good one.
struct a
  char data1;
  int data2;
  float data3;
  char data4;

ofstream file(name, ios::binary);
a myStruct;
myStruct.data1 = 'a';
myStruct.data2 = 1024;
myStruct.data3 = 5.3;
myStruct.data4 = 'z';
file.write((char*)&myStruct, sizeof(a));
a dat;
ifstream f(name, ios::binary);
f.read((char*)&dat, sizeof(a));
cout << dat.data1 << endl;
cout << dat.data2 << endl;
cout << dat.data3 << endl;
cout << dat.data4 << endl;