c++ 文件复制 程序 及问题
我的程序可以达到小甲鱼老师说的复制文件。可还是和原来的文件有差别,就是把原来的空格和回车行没了?#include <FSTREAM>
#include <IOSTREAM>
using namespacestd ;
int main(int argc , char *argv[])
{
if (argc != 3)
{
cerr << "cppyfilesourcesdest\n";
exit(EXIT_FAILURE);
}
ifstream in( argv, ios::in );
if ( !in )
{
cerr << "open file fail" << endl ;
return 0;
}
ofstream out( argv, ios::out );
if ( !out )
{
cerr << "open fiel fail" << endl;
in.close();
return 0;
}
char x;
while ( in >> x )
{
out << x ;
}
out << endl;
in.close();
out.close();
cout << " copy afile success !" << endl;
system("pause");
return 0;
}
页:
[1]