char byte;
ifstream f("file");
while (1) {
f >> byte;
if (!f.eof()) cout << byte << '\n'; else break;
}
Mind the break to escape the while on eof found: no additional
iteration.
The idea is here; modify at will!
Geraldo
--- In [email protected], Jos Timanta Tarigan
<[EMAIL PROTECTED]> wrote:
>
> Hi,
> Im currently try to read a binary file. Im using this loop
>
> while(!f.eof() {do.something()}
>
> to do the loop. I notice that this method is nor recommended since
there will be an additional loop at the end. How can I loop a binary
file without using this loop? What is the other way to do it?
>
> Thank you
>
>
> Regards
>
> Jos Timanta Tarigan
>