// file_eof.c -- open a file and display it
#include <stdio.h>
// for exit()
#include <stdlib.h>

int main(void)
{
	int ch;
	FILE * fp;
	// to hold the file name
	char fname[50];

	printf("Enter the name of the file: ");
	scanf("%s", fname);
	// open file for reading
	fp = fopen(fname, "r");

	if (fp == NULL)
	{
		// attempt failed
		printf("Failed to open file. Bye\n");
		// quit program
		exit(1);
	}
	// getc(fp) gets a character form the open file
	while ((ch = getc(fp)) != EOF)
		putchar(ch);

	fclose(fp);
	return 0;
}
