My point is to make a program that could read from given file byte by byte.. somehow it turned out for me not to be as easy so i simplified my code till it became the fraction below. The thing is that my ifstream object stops reading at some point and returns just 0xFF bytes until the end of the reading. Most probably I just don't properly understand the function of this stream. In the case you saw where is the problem, please let me know, you would probably save at least one day of my life.thx
You need to open the file as binary, otherwise, it's opened as text and fstream does some pretty annoying things. std::ifstream fin("data",std::ios::binary);
By the way, it's much more common to read the entire file or chunks thereof into a an array, than read it byte by byte. It's a lot faster.
I tried to open it as binary, but already the first byte threw failbit and eofbit. When I removed that ios::binary ... flag? it worked for that incomplete part again. Btw about the speed I thought there is automaticaly initialized some filebuffer.. or do I need to create some explicitly?