FILES(3)

NAME
files - file handling subroutines with error checking nn_fopen, nn_fclose

SYNOPSIS
#include <stdio.h>

FILE *nn_fopen(fname, type, for_message)
char *fname, *type, *for_message;

void nn_fclose(ptr, filename, for_message)
FILE *ptr;
char *filename, *for_message;

DESCRIPTION
These are copies of the routines fopen() and fclose() with error checking added. nn_fopen opens the file named by fname and associates a stream with it. The string type is used by fopen to determine if the file is to be opened for reading or for writing or for both. The available strings and their meanings are given on the fopen manual page. If the open succeeds, nn_fopen returns a pointer to the stream. If the open fails, an error message is printed and the program exits. The string for_message is used in that error message to describe what the file was being opened for. nn_fclose closes a stream opened by nn_fopen. If the close fails, an error message is printed giving the name of the file and some reason for its being opened.

SEE ALSO
fopen(3V), fclose(3V), fatal_error(3)