?
Solved

merging and copying files to anther directory

Posted on 2003-02-26
2
Medium Priority
?
173 Views
Last Modified: 2010-04-15
I need some immediate help with this:
suppose i would generate two files, file a and file b,c
file a's path is /usrs/extracts/work/a.txt
file b's path and name: /users/extracts/work/b.txt
/users/extracts/wrok/c.txt

I need to do these:
1. before i generate files in work dir, clean/delete all files in this dir. how to do that? using system(  ) func?
2. Then i generated two files in this dir, a and b. how to merger them(append them) to anther dir /users/extracts/ready dir to have a final file:
/users/extracts/ready/d.txt? Any code there which would efficiently doing that(speed and correctness)? a.txt and b.txt, c.txt might be big and each has thousands of record with each record 80bytes.
thanks for help
0
Comment
Question by:pigyc
2 Comments
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 400 total points
ID: 8024785
To merge two files using system() fuction, you use the following parameter

system("cat a.txt b.txt > d.txt");

for further help write comments.
0
 

Author Comment

by:pigyc
ID: 8026700
how is the speed of this cat method?
I read about ways of something like this,using append method. Facing these two choices , what you would choose interms of speed and correctness, and why?

...open c.txt for read, and get c_fptr.....--->should it open for append instead of read for c.txt??

while(fgets(linebuff, sizeof(linebuff), a_fptr)
  if(fputs(linebuff, c_fptr)==EOF){
   fclose(a_fptr);   ---->should it close c_fptr instead??
 }

 if(!feof(a_fptr))
   fclose(a_fptr);

..do the samething to b.txt to append to c.txt.....

fclose(c_fptr);
0

Featured Post

Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question