I\'m trying to load binary file using fstream in the following way:
#include
#include
#include
#include
The main question probably is what you mean by "binary file". The ios::binary only makes sure that the istream object doesn't replace platform-specific newlines by '\n'. Nothing else. Is that enough for you?
An istream_iterator basically is just a fancy way to invoke operator>>. If you have real binary data in your stream, that will fail. Do you have real binary data in your file? Or are the integers stored as strings?
If you need to read real binary integers, what you need is either istream.read() or using the stream buffer object directly.