C++ program to copy content of one FILE to another FILE

#include <iostream>
#include <fstream>
#include <stdlib.h>>
using namespace std;
int main()
{
    char sourceF[]="MyFile.txt",destF[]="Deep.txt",ch;
    ifstream in(sourceF);
    ofstream out(destF);
    if(in.bad())
    {
        cout<<"Error in opening file....";
        exit (1);
    }
    in.get(ch);
    while(in.eof()==0)
    {

        out.put(ch);
        in.get(ch);
    }
    in.close();
    out.close();
    return 0;
}

No comments:

Post a Comment