#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int
main(int argc, char **argv)
{
  clock_t temps=clock();
  FILE * fd1, *fd2;
  int rc;
  int i=0;
  if(argc != 3) { fprintf(stderr, "Syntaxe: %s f1 f2\n", argv[0]); exit(1); }
  
  fd1 = fopen(argv[1],"r");
  if(fd1 == NULL) { perror("ouverture"); exit(1); }
  
  fd2 = fopen(argv[2], "w+");
  if(fd2 == NULL) { perror("ouverture"); exit(1); }

  while(1) {
    rc = fgetc(fd1);
    if(rc == EOF) { perror("Fin"); break; }
    if(rc == 0) break;
    rc = fputc(rc, fd2);
    if(rc < 0) { perror("Erreur sur fputc"); exit(1); }
    for(;i<10000;i++)fprintf(stderr,"yo");
  }
  
  fclose(fd1);
  fclose(fd2);
  printf("temps : %f secondes\n",clock()-temps);
  return 0;
}

