#include
#include
#include
#include
#include
void main()
{
ofstream outfile;
ifstream infile;
char fname1[10],fname2[10];
char ch,uch;
clrscr();
cout<<"enter a file name to be copied?\n";
cin>>fname1;
cout<<"new file name ? \n";
cin>>fname2;
infile.open(fname1);
if (infile.fail())
{
cerr << "No such a file exists \n";
exit(1);
}
outfile.open(fname2);
if(outfile.fail())
{
cerr<< "unable to create a file \n";
exit(1);
}
while(!infile.eof())
{
ch=(char)infile.get();
uch=toupper(ch);
outfile.put(uch);
}
infile.close();
outfile.close();
}//end of main
OUTPUT:
enter a file name to be copied?
xxx.dat
new file name ?
yyy.dat
contents in xxx.dat
abcdefgh
contents in yyy.dat
ABCDEFGH
No comments:
Post a Comment