Link to home
Start Free TrialLog in
Avatar of pigyc
pigyc

asked on

merging and copying files to anther directory

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
ASKER CERTIFIED SOLUTION
Avatar of rajeev_devin
rajeev_devin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pigyc
pigyc

ASKER

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);