Read Character from File

#include<stdio.h>
#include<conio.h>
void main()
{
          FILE *fp;
          char ch;
          clrscr();
          fp=fopen("temp.txt","r");
          if (fp==NULL)
            {
                   printf("\n Error");
                   exit(0);
            }
          // write character to file
          printf("\n\nData in file : \n");
          while((ch=fgetc(fp))!=EOF)
            {
                   putch(ch);
            }
          fclose(fp);
          getch();
}

Post a Comment

Previous Post Next Post