Binary file and structs

Hello. What is the difference between reading from binary file between the following way:

1
2
3
4
5
6
7
8
9
struct aStrct{

   int number;

}vars[];
while(file.good())

    file.read((char*)&vars, sizeof(aStrct))


And

1
2
3
4
5
6
7

while(file.good())

    file.read((char*)&vars[i], sizeof(aStrct))

    i++;
The difference is that one is incorrect, and the other is slightly less incorrect.
Last edited on
pls explain which ones? I used the second one in a code and it is working fine
Last edited on
Topic archived. No new replies allowed.