Skip to main content
Write a program to display contents of file on the screen. The program should ask for file name. Display the contents in capital case.
CODING:

#include <stdio.h>
#include<conio.h>
void main()
{
 FILE *fp;
 char ch,fname[13];
 clrscr();

 printf("\nEnter file name : ");
 gets(fname);
 fp=fopen(fname,"r");

 if(fp==NULL)
 {
printf("Error in finding file.");
getch();
exit();
 }
 printf("\nText in file :\n");

 while(!feof(fp))
 {
ch=fgetc(fp);
printf("%c",toupper(ch));
 }
 fcloseall();

 getch();
}

Comments