Click here to Skip to main content
13,046,087 members (58,294 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 5 Feb 2007

Binary File Copy

, 5 Feb 2007
Rate this:
Please Sign up or sign in to vote.
A C++ program to read/write files in binary mode.

Filename : BinaryFileIO.cpp

Author : Pawan Pillai

Description : A C++ program to read/write files in binary mode.
The user itself specifies the number of bytes to be read,
and the code runs a loop until the whole file is copied
at the destination.

Cool points:

1) uses loop to read andd write the bytes, thus clears the concept of reading files when file size is large.

2) shows the use of funtion gcount() whose implementation is missing in most of the tutorials.

3) the user can alter the value of variable "num_of_bytes", thus a value larger than the size of the file can also be used for experimenting purposes.

4) highly commented code, thus clarifies everything in the code.


the name "umg.rar" is the name of input file, it should be changed to the user specific filename, also the path for sorce file and destination files should also be changed as per requirement.


This is my first code which i am publishing online, just because i thought there are almost no code available online to demonstrate file copy in binary taking a loop. (if there are, then i am sorry).
I hope you like the code.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

India India
My name is Pawan Pillai.
I am an Information Technology Engineer from India.
I like programming in C, C++ and Java.
My interests are watching movies, playing cricket and table tennis and surfing internet for almost anything.

You may also be interested in...

Comments and Discussions

GeneralWorks Perfect Pin
rajmajama24-May-11 15:56
memberrajmajama24-May-11 15:56 
GeneralThanks Pin
Ident827-Jan-10 17:59
memberIdent827-Jan-10 17:59 
GeneralMy vote of 1 Pin
Bartosz Wojcik5-Dec-09 13:08
memberBartosz Wojcik5-Dec-09 13:08 
GeneralMy vote of 1 Pin
Tsuda Kageyu2-Dec-09 3:46
memberTsuda Kageyu2-Dec-09 3:46 
GeneralBinary Copy Code Pin
C++_Rabbit27-Jun-08 16:53
memberC++_Rabbit27-Jun-08 16:53 
GeneralJust what I was looking for Pin
Rob.Kinney14-Jun-07 8:15
memberRob.Kinney14-Jun-07 8:15 
QuestionHow to use ifstream & ofstream with unicode (16 bit wchar_t) file name? Pin
Tongle The Great6-Feb-07 2:25
memberTongle The Great6-Feb-07 2:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Feb 2007
Article Copyright 2007 by Pawan84
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid