Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

merging and copying files to anther directory

Posted on 2003-02-26
2
Medium Priority
?
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

721 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