#include <stdio.h>


#ifndef __cplusplus
typedef enum { false, true } bool;
#endif

bool CopyFile(const char *source, const char *target)
{
  char buffer[1024];
  long bytesread;
  bool result;
  
  FILE *fpSrc = fopen(source, "rb");
  FILE *fpTrg;

  if(!fpSrc)
    return false;

  fpTrg = fopen(target, "wb");
  if(!fpTrg)
  {
    fclose(fpSrc);
    return false;
  }
  
  result = true;
  while(!feof(fpSrc))
  {
    bytesread = fread(buffer, 1, sizeof(buffer), fpSrc);
    if(bytesread)
      if(fwrite(buffer, 1, bytesread, fpTrg) != bytesread)
      {
        result = false;
        break;
      }
  }
  
  fclose(fpSrc);
  fclose(fpTrg);
  
  return result;
}

void main(int ArgC, char *ArgV[])
{
  if(ArgC > 2)
    if(!CopyFile(ArgV[1], ArgV[2]))
      perror("CopyFile");
    else
      puts("Arquivo copiado");
}
1