/*
 * L I S T _ 3
 *
 * Display the contents of an ASCII text file
 * file on the user's screen.
 *
 * NOTE: This version uses string functions.
 */

#include <stdio.h>

#define MAXPATH 64
#define MAXLINE 256

int
main(void)
{
	int ch;                 /* input character */
	FILE *fp;               /* file pointer */
	char pathname[MAXPATH]; /* filename buffer */
	char line[MAXLINE];     /* line buffer for fgets() */

	/*
	 * Prompt the user for a filename and read it.
	 */
	printf("Filename: ");
	gets(pathname);
	if (*pathname == '\0')
		return (0);

	/*
	 * Open the named file for reading.
	 */
	fp = fopen(pathname, "r");

	/*
	 * Read the contents of the file and display it
	 * a line at a time as it is read.
	 */
	while (fgets(line, MAXLINE, fp) != NULL)
		fputs(line, stdout);

	/*
	 * Close the file.
	 */
	fclose(fp);

	return (0);
}
