Any alternative ways of reading data from binary files?

Hello all.
Suppose I'm reading some doubles from a binary file.
I can do this:
myBinaryFile.read(reinterpret_cast<char *> (&myDouble), sizeof (double));

Yuck. That is nasty. The code is also nonportable to machines of different endianness, different sizes of types, or maybe it's the file itself that's not portable lol? Thanks C++.

So I'd like to know if there are better methods I could employ for reading things from binary files. Maybe there's something I forgot about?
Read into a char[sizeof(double)] and move bytes around as needed. Although for maximum portability, I would just not mix binary files and floating points at all, or I would find some way to decompose the number into mantissa and exponent and then store these myself.
Bump.
Any ideas to get operator >> to work with "unformatted" input of data?
Topic archived. No new replies allowed.