Tuesday, October 21, 2014

Implemented a program with C++ that read a text file and creates another file that is identical to it

#include<fstream.h>
 void main()
 {
    char source[67],target[67];//max allowable path length usually 66
    char ch;
    cout<<"\n Enter souce filename=";
    cin>>source;

    cout<<"\n Enter target filename=";
    cin>>target;

    // create file for input
    ifstream infile(source);

    //create file for output
    ofstream outfile(target);

    //continue reading file until EOF is reached
    while(infile)
    {
        infile.get(ch);
      outfile.put(ch);
    }
 }

No comments:

Post a Comment