Use read() for binary input: file.read(reinterpret_cast<char*>(&data), sizeof(data));. This reads sizeof(data) bytes directly into memory. Works for integers, structs, or arrays. The reinterpret_cast converts your pointer to char* (the type read() expects).
You're copying raw bytes from file to variable, no formatting or conversion happens. Check gcount() after reading to see how many bytes were read: if(file.gcount() != sizeof(data)) { /* partial read */ }.
End-of-file or errors cause short reads that corrupt your data if unchecked.