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

extern int errno;

int main()
{
  FILE *fin = NULL;
  int read_input = 0;

  // open a file
  //fopen()

  fin = fopen("hello.c","r");
  //if the return value of fopen is NULL, bad file, otherwise, fine
  
  if(NULL==fin)
  {
    //
    fprintf(stderr,"error: problem %d opening file\n", errno);
    fprintf(stderr,"%s\n", strerror(errno));
    //output some sort of error message
    return -1;
  }

  //read from it
  // while i have more input (not reached end of file), get next char
  while(EOF!=(read_input=getc(fin)) ) 
  {
    fputc(read_input,stdout);
  }

  //close the file
  // fclose()
  fclose(fin);

  return 1;
}
