Copiar un archivo: C++

Acabo de terminar un programa de ejemplo en c++ que copia dos archivos, espero que te sea de utilidad.

#include <iostream>
#include <fstream>

using namespace std;

int main (int argn, char * argv[])
{
    if(argn < 3) return 1;

    ifstream in(argv[1], ios::binary);
    if(!in.is_open())
        return 2;

    ofstream out(argv[2], ios::binary);
    if(!out.is_open())
        return 3;

    in.seekg(0,ios::end);
    long size = in.tellg();
    in.seekg(0,ios::beg);
    size -= long(in.tellg());
    cout << "FileSize: " << size << "bytes" << endl;

    char * buffer;
    long buffsize = size;

    do
        buffer = new char [buffsize];
    while (!buffer && bool(buffsize/=2));

    cout << "BuffSize: " << buffsize << "bytes" << endl;

    while(size > buffsize)
    {
        in.read(buffer,buffsize);
        out.write(buffer,buffsize);
        //if(!out.good()) return 4;
        size -= buffsize;
    }

    if(size != 0)
    {
        in.read(buffer,size);
        out.write(buffer,size);
    }

    in.close();
    out.close();

    return 0;
}

Comentarios