Write the c program to read the data of the file & display the data on the screen if file not exist create the file

#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char fname[20],ch;
clrscr();
printf("\n enter the file name\n");
gets(fname);
fp=fopen(fname,"r");
if(fp==NULL)
{
printf("\n unable to open");
exit(0);
}
else
{
while(ch!=EOF)
{
ch=fgetc(fp);
printf("%c",ch);
}
}
fclose(fp);
getch();
}

Comments