Introduction
slide 4
slide 5
A Longer Example
#include <stdio.h>
int fclose(FILE *stream);
int fprintf(FILE *stream, const char *format,...);
/* [On the system we used in 1994, it was unfortunately sometimes
necessary to explicitly declare library prototypes. -- 19 May 1996] */
typedef char * string;
typedef short unsigned int bool;
#define TRUE (1)
#define FALSE (0)
/* util.c prototypes */
void usage(const string name);
string basename(string command);
bool close_file(const string name, const string proc, \
const string fname, FILE * handle);
FILE * open_file(const string name, const string proc, \
const string fname, const string mode);
/* Before you comment on my use of `const string' please read the errors section of the introduction */
#include "main.h"
static int open_files = 0; /* number of files currently open */
.
.
.
bool close_file(const string progname, /* name of the program */
const string proc, /* name of function calling */
const string fname, /* filename of file to close */
FILE * handle) /* the file to be closed */
{
if (fclose(handle) == EOF) {
fprintf(stderr, "%s[%s()] Error: cannot close file `%s'\n",
name, proc, fname);
return(FALSE);
} else {
open_files--;
# if DEBUG > 1
fprintf(stderr,"%s() closed %s\n", proc, fname);
# endif
return(TRUE);
}
} /* close_file() */
Introduction
List of Contents
a longer example
Last updated by J. Blustein on 28 May 1996.
This document is copyright by its author, J. Blustein <jamie@csd.uwo.ca>.