#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

int main (int argc, char *argv[]){
  FILE *fileIn, *fileOut ;

  if (argc != 3) {
    fprintf(stderr, "Usage: %s inputfile outputfile\n", argv[0]) ;
    exit(235) ;
  }

  fileIn = fopen(argv[1], "r") ;
  if (fileIn == NULL) {
    fprintf(stderr, "Unable to open input file %s: %s\n",
	    argv[1], strerror(errno)) ;
    /*
     *  It would be wise to be conservature about opening the second
     *  file for output after the first one had failed...
     *  access is in the POSIX API...
     */
    if (!access(argv[2], W_OK)) {
      fprintf(stderr, "Unable to write output file %s: %s\n",
	      argv[2], strerror(errno)) ;
    }
    exit(235) ;
  }

  fileOut = fopen(argv[2], "w") ;
  if (fileOut == NULL) {
    fprintf(stderr, "Unable to open output file %s: %s\n",
	    argv[2], strerror(errno)) ;
    exit(235) ;
  }

  fprintf(stdout, "Well.... still working\n") ;
  return 0 ;
}
