C++ Program .Write a program to read data from text file and display data on screen, if file dose not exit then create it.



#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp; /* file pointer*/
char ch;
clrscr();
fp=fopen("k.txt","r");/*open a file*/
while((ch=fgetc(fp))!=EOF)
   {
   printf("%c",ch);
   }
   fclose(fp);
   if(fp==NULL)
   {
   fp=fopen("k.txt","w");
   }
getch();
}