Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
833 B
2
Indexable
Never
int main()
{
    ifstream fs;
    ofstream fd;
    string str;
    char sourcefile[100],destinatio[100];
    cout<<"enter source file with extension";
    gets(soucrefile);
    fs.open(sourcefile);
    if(!fs)
    {
        cout<<"error in opening";
        exit(1);
    }
    cout<<"enter destination file with extension:"<<endl;
    gets(destinationfile);
    fd.open(destinationfile);
    if(!fd)
    {
        cout<<"error in opening destination file";
        fs.close();
        exit(2);
    }
    if(fs&&fd){
        while(getline(fs,str))
        {
            fd<<str<<endl;
        }
        cout<<"\n\n source file data sucessfully copied";
    }
    else {
        cout<<<"file cannot open";
    }
    cout<<"\n\n open destination file and check\n";
    fs.close();
    fd.close();
}
Leave a Comment