/*
 * L I S T _ 2
 *
 * Display the contents of an ASCII text file
 * file on the user's screen.
 *
 * NOTE: This version lets the user specify a filename.
 */

#include <stdio.h>

#define MAXPATH 64

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

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

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

	/*
	 * Read the contents of the file and display
	 * each character as it is read.
	 */
	while ((ch = fgetc(fp)) != EOF)
		putchar(ch);

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

	return (0);
}
