hi
i am a novice c++ programmer and am facing a problem in file input
when ever i try to read from file to copy it to other the spaces and
enter is file are missed
the code is as following
#include<fstream>
#include<iostream>
#include<process.h>
using namespace std;
int main(int argc,char *argv[])
{
fstream file1;
fstream file2;
char a;
char fn1[1024],fn2[1024];
cout<<"enter source file ";
cin.get(fn1,1024);
file1.open(fn1,ios::in);
if(file1.fail())
{
cout<<"error file cant be opned\n";
exit(0);
}
else
{
cout<<"file opened succesfully\n";
}
cout<<"enter destination file name";
cin>>fn2;
file2.open(fn2,ios::out);
if(file2.fail())
{
cout<<"error file cant be opned\n";
exit(0);
}
else
{
cout<<" file is opened";
}
while(!file1.eof())
{
file1>>a;
file2<<a;
}
file1.close();
file2.close();
return -1;
}