Código C++:
Ver original#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main (int argc, char **argv)
{
const int TAM_BUFFER = 512;
char buffer [TAM_BUFFER];
ifstream fi;
ofstream fo;
if (argc != 2) {
cerr << "Error: Numero de argumentos incorrecto\n";
cerr << "Formato: " << argv[0]<< " <fich_in> <fich_out>\n";
}
fi.open (argv[1]);
if (!fi) {
cerr << "Error: no pudo abrirse " << argv[1] << endl;
}
fo.open(argv[2], ios::binary);
if (fo.fail())
{
cerr << "Error: No pudo crearse " << argv[2] << endl;
}
while (fi.read(reinterpret_cast<char*>(buffer), TAM_BUFFER))
fo.write(buffer, TAM_BUFFER);
fo.write(buffer, fi.gcount());
fi.close ();
fo.close ();
return (0);
}