Total members 11890 |It is currently Wed Apr 24, 2024 12:57 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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?




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

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!

_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Read Binary File in C++
 read from file in C++     -  
 Read csv file     -  
 read file in matlab     -  
 Read and write CSV file     -  
 File write read     -  
 Read and Write to file using ASP     -  
 File read by char     -  
 javascript read file     -  
 Read XML file content using SAX and writing its as SQL     -  
 read php file in asp and display it as html     -  



Topic Tags

C++ Files and I/O






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com