#include<iostream.h>
#include<conio.h>
#include<fstream>
#include<stdlib.h>
void main() {
ofstream outfile;
ifstream infile;
char fname1[10],
fname2[20];
char ch,uch;
clrscr( );
cout<<"Enter a file name to be copied ";
cin>> fname1;
cout<<"Enter new file name";
cin>>fname2;
infile.open(fname1);
if( infile.fail( ) )
{
cout<< " No such a file Exit";
getch();
exit(1);
}
outfile.open(fname2,ios::noreplace);
if(outfile.fail())
{
cout<<"File Already Exist";
getch(); exit(1);
}
else
{
while(!infile.eof( ))
{
ch = (char)infile.get( );
outfile.put(ch);
}
}
infile.close( );
outfile.close( );
getch( );
}