Write a programe in c language to get file name from user and read it. If file name does not exist then print file does not exist

4/21/2013 04:51:00 pm Unknown 0 Comments



#include <stdio.h>
#include <conio.h>
main()
{
   
FILE *fp;
char a, read;
char b[]="fahad.txt";
again:
printf("\nEnter name of file: ");
scanf("%s", &b);
fp=fopen(b, "r");
if(fp==NULL)
{
            printf("\nFile is Empty or not exist.\n");        
}
else
{
    while(read!=EOF)
    {
                    read=getc(fp);
                    printf("%c", read);            
    }
}
printf("\nYou want read again data from file? Y/N");
         a=getch();
         if(a == 'y' || a == 'Y')
         {
              printf("\n");
                goto again;    
         }
}