Hi there. Few days ago I desided to create small program that would copy any file. But I met some realy serios problem: if file I want to copy is not a txt-file(*.wav, *.bmp, *.doc etc.) my program copies few symbols and closing file. Here's simplefied version of my program:
#include <fstream.h>
int main(int argnum, char* argu[])
{
if (argnum == 1)
{
cout << " File Copier V1.0 " << endl;
cout <<'\n'<< " Usage: filecpy.exe file1 file2 " << endl;
return 1;
};
ifstream infile (argu[1]);
ofstream fileout (argu[2],ios::app);
if( ( !infile ) || ( !fileout) )
{
cout << "\n ERROR! Enable to open/create file ! \n";
return 1;
};
char ch[60];
infile.unsetf(ios::skipws);
while (!infile.eof())
{
infile >>ch;
fileout << ch;
};
infile.close();
fileout.close();
return 0;
}
Please help me solve that problem, it realy holding be back. Thank You.