Computer Science, asked by prernaaSaraswat21, 24 days ago

wap in c to read contents from a file​

Answers

Answered by MrTSR
3

C O D E

#include <stdio.h>

#include <stdlib.h>

int main()

{

   FILE *file;

   char c;

   file = fopen("brainly.txt", "r"); // enter the name of file.

   while (1)

   {

       if (file == NULL)

       {

           printf("File Not Found\n");

           exit(0);

       }

       else

       {

         c = fgetc(file);

           if (c == EOF)

           {

               break;

           }

           printf("%c", c);

       }

   }

   fclose(file);

}

Attachments:
Similar questions