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.tx t? 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
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.tx
thanks for help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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);