I am really baffled and cannot figure out what the problem here is. I am writing 3 Integers to a file and try to read them later again. But I get some random data. I checked the binary file with an hex editor, and the integers are written just fine.
First in your write function you should really be opening the file in binary mode. In your read function you should also be opening the file in binary mode, and use read() (the opposite of write) instead of the extraction operator.