Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to copy file in C?

Status
Not open for further replies.

rahul_sanghavi

Member level 2
Joined
Dec 7, 2004
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
404
copy file in c

Hi

I want to copy .doc, .xls & image file into another same file in C.

Is there any rules for this?

Regards
 

Pinczakko

Full Member level 2
Joined
Jul 29, 2004
Messages
138
Helped
13
Reputation
26
Reaction score
0
Trophy points
1,296
Location
Taka Bonerate National Park, Indonesia
Activity points
1,592
c copy file

No exact rules, as long as you make exact binary copy of the file. You can use the following steps:
1. Open the source file in binary mode with fopen(... rb ).
2. Open the new file buffer, i.e. destination file with fopen(... wb).
3. Copy the contents by utilizing the file handle from step 1 and 2. You can use read(...) and write(...) or other C library function for that.

goodluck :wink:
 

rahul_sanghavi

Member level 2
Joined
Dec 7, 2004
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
404
copy file c

Hi,

If i follow ur instruction for copy file in c. but it's work for .txt only but if i copy .doc or .xls etc. file than this file cannot copy properly.

Regards
 

saeid5977

Junior Member level 2
Joined
May 23, 2006
Messages
23
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,283
Activity points
1,471
file copy in c

hi,
which platform u r programming?
if u r use windows u can use from it's API for it
(CopyFile & CopyFileEx)
and in pure C u can use fread and fwrite but u should use "rb" and "wb" for opening files. if want i send u source code.
 

rahul_sanghavi

Member level 2
Joined
Dec 7, 2004
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
404
copy a file in c

Oh wow!!

It's work!!!

Thanks


Regards
Rahul Sanghavi
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top