Switch to full style
For C/C++ coders discussions and solutions
Post a reply

Read Binary File in C++

Sat Nov 08, 2008 1:23 am

Im currently try to read a binary file. Im using this loop

Code:
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?



Re: Read Binary File in C++

Sat Nov 08, 2008 1:25 am

Code:
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!

Post a reply
  Related Posts  to : Read Binary File in C++
 read from file in C++     -  
 Read csv file     -  
 File read by char     -  
 javascript read file     -  
 read file in matlab     -  
 Read and write CSV file     -  
 Read and Write to file using ASP     -  
 File write read     -  
 Read Arabic text from file     -  
 How to read and write to CSV file from python     -  

Topic Tags

C++ Files and I/O