Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

existing files

Posted on 2000-03-24
2
Medium Priority
?
263 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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

782 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