I am in the need of using binary I/O in C++ and as I've never done this before, did some searching to find information on the subject. After a while of searching, I still couldn't find material that fully describes the topic. Maybe there is a book/article/tutorial that covers the subject? (reading all kinds of data, int's, strings, arrays etc. )
From the little I found, I have a specific question regarding the reading of an int.
I'm opening the file, setting the get pointer to the beginning of the file, reading sizeof(int) bytes of the file, which is one integer. Why do the outputs differ? (first is 64, second - 168637494). Do i have to cast that variable every time i need to use it?
Assuming you have int Width, then after reading it from the file, you simply need std::cout << Width << "\n";
In your example, line 5 doesn't make much sense to me. It is trying to display the address of the variable Width but asking for that address to be interpreted as a pointer to a string of characters instead. However, if the data file really did contain a string of characters, then it should have been treated directly as such.