C++ Program Write a ‘C’ Program to read data from a text file & display data on the screen, if file is not exist then create it.





#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;//      FILE OPEN
char ch;
clrscr();
fp=fopen("a.txt","r");//FILE OPEN FOR READ MODE
if(fp==NULL)
{
printf("\n Unable To Open a File");
}
while((ch=fgetc(fp))!=EOF)
{
 putchar(ch);
}
fclose(fp);
getch();
}
/*output
all indians  are my brothers and sisters */