define MAX_LINE 1024
void DisplayFile(void)
{
char filename[FILENAME_MAX];
FILE *infile;
// Prompt the user for a filename
puts("Enter the filename to display: ");
// Get the user's input (unsafe function call!)
gets(filename);
// Open the file in binary mode
infile = fopen(filename, "rb");
// If successful, read each character and display it
if (infile)
{
// Until we reach the end
while (!feof(infile))
{
// Get a character and display it
int c = fgetc(infile);
putc(c, stdout);
}
// Close the file
fclose(infile);
}
else
perror(filename); // couldn't open the file
}