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

void byebye() ;

int main(int argc, char *argv[]) {
  char bigCharBuffer[1024] ;
  int numRead ;
  int inFD, outFD ;
  if (argc < 3) {
    byebye() ;
  }
  inFD = open(argv[1], O_RDONLY) ;
  outFD = open(argv[2], O_CREAT) ;
  if (inFD == -1 || outFD == -1) {
    byebye() ;
  }
  while ((numRead=read(inFD, (void *)bigCharBuffer, 1024)) > 0) {
    write(outFD, (void *)bigCharBuffer, numRead) ;
    // write(1, (void *)bigCharBuffer, numRead) ;
  }
}

void byebye() {
  write(2, "byebye\n", 7) ;
  exit(1) ;
}
