Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 8:31 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: Read Binary File in C++
PostPosted: Sat Nov 08, 2008 1:23 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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?


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Read Binary File in C++
PostPosted: Sat Nov 08, 2008 1:25 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 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!


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 Image Insert in Excel File Using POI
 ASP file structure
 Read your gmail using Java code
 Search records from text file
 error closing file matlab save
 read ibooks on pc
 How to download any file in jsp.
 read php file in asp and display it as html
 javascript read file
 How to make PHP form data saved into txt file

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team