To read a text file print it on the screen in C


Levels of difficulty: / perform operation:

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	FILE *fp;
	char s;
	clrscr();
	fp=fopen("text.txt","r");
	if(fp==NULL)
	{
		printf("\nCAN NOT OPEN FILE");
		getch();
		exit();
	}
	do
{
		s=getc(fp);
		printf("%c",s);
	}
	while(s!=EOF);
	fclose(fp);
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview