Solved

existing files

Posted on 2000-03-24
2
227 Views
Last Modified: 2010-04-02
how do i use the 2 void function//
for instance for the 1st function i have to read and copy the contents of file01.dat and file02.dat into a 3rd file..
so can someone please help how to do the producers for the file I/O.. and also
i also wanted to know how in them  2nd function to read the merged file from data 3rd file.. so can someone please
show  me an example like this..
0
Comment
Question by:best2380
2 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2654473
What do you mean by "use the 2 void function"?  That doesn't make sense?

>> 1st function i have to read and copy the
>> contents of file01.dat and file02.dat into a
>> 3rd file
Just use 3 fstream objects to open the 3 files.  Read all the information out of the fstream objects for file01 and file02 and write that information to file03.
0
 

Accepted Solution

by:
kishore_joshi earned 20 total points
ID: 2689578
// to merg two files into the third file

void merg()
{
      char ch;
      ifstream f1("file01.dat"), f2("file02.dat");// two objects to read

      fstream d1;
                d1.open("file03.dat",ios::app);  // open in append mode
      
               do
      {
            f1.get(ch);
            d1<<ch;

      }while(ch != EOF);
             
               do
      {
            f2.get(ch);
            d1<<ch;

      }while(ch != EOF);

             d1.close(); // close the destination file.
}

/// to read the data that is merged
void merg_read()
{
              char ch;
              ifstream d1("file03.dat");// d1 objects to read data from file03
      
               do
      {
            f1.get(ch);
            cout<<ch;

      }while(ch != EOF);

}
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

777 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