The following is a code that my teacher gave me .. I dont know the working of files in c++ :( this program is supposed to copy a datafile into another.. but its is not working ... many many errors.. fname1 and fname2 are already existing files,right? or fname2 is being created.. please help me understand the mechanism
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<process.h>
class file
{char fname1[20],fname2[10];
ifstream infile;
ofstream outfile;
cout<<"Enter the first file name ";
cin>>fname1;
infile.open(fname1;ios::ch);
if(!infile)
{
cout<<"File doesnt exist";
getch();
exit(0);
cout<<"Enter the second file name ";
cin>>fname2;
outfile.open(fname2,ios::out/ios::tranc);
while(!infile.ch())
{
infile.get(ch);
outfile.get(ch);
}
cout<<"file written successsfully ";
void file::closefile(){
infile.close();
outfile.close();
}
getch;
}