Total members 11894 |It is currently Sat Nov 23, 2024 11:20 am 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 csv file     -  
 read from file in C++     -  
 File read by char     -  
 javascript read file     -  
 read file in matlab     -  
 Read and write CSV file     -  
 File write read     -  
 Read and Write to file using ASP     -  
 Write and Read to File In Java Example     -  
 Read Arabic text from file     -  



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