Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,557 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,602 people online right now. Registration is fast and FREE... Join Now!




I want to write a code in C to transfer a file.How do i do that?

 
Reply to this topicStart new topic

I want to write a code in C to transfer a file.How do i do that?

karishmabagga
23 Nov, 2007 - 03:22 AM
Post #1

New D.I.C Head
*

Joined: 23 Nov, 2007
Posts: 1


My Contributions
I want to write a code in C to transfer a file.How do i do that?
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: I Want To Write A Code In C To Transfer A File.How Do I Do That?
23 Nov, 2007 - 06:35 AM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,868



Thanked: 53 times
Dream Kudos: 550
My Contributions
please see the forum rules.

Well the word "transfer" makes your question rather ambiguous. If you mean to copy a file there are a number of ways.

The basic procedure is to open a file for reading (binary) and one for output (again binary) and then loop though copying blocks from the in file to the out file. STL even has a copy function that can take the contents of the source file and copy it to a destination.

many people who are new to C/C++ like to use the system() function to just call the operating system's copy command. It may not be the most portable but a little batch file or shell script to wrap the operating system's command name and it can be made portable.

system("copy source dest"); //Windows/DOS
system("cp source dest"); //Linux/Unix

If by "transfer a file" you mean upload/download across a network or internet, well that is a different story (or even a couple of different stories).
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 10:05PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month