Solved

existing files

Posted on 2000-03-24
2
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now