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

x
?
Solved

existing files

Posted on 2000-03-24
2
Medium Priority
?
256 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
[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 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 60 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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 learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

670 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