A file represents a sequence of bytes on the disk where a group of related data is stored. The file is created for the permanent storage of data.

Syntax :

FILE *ptr;

ptr=fopen(“File_Name”,”Mode”);

File operation

  1. Creation of a file
  2. Opening a file
  3. Reading a file
  4. Writing to a file
  5. Closing a file

File Function

  • fopen()   create a new file or open an existing file
  • fclose()  closes the file
  • fprintf()  write the set of data in the file
  • fscanf()  read the  set of data from the file
  • fputc()   write a character in the file
  • fgetc()   read the character from a file
  • fputs()   write a String in the file
  • fgets()   read the string from a file

Watch the Video Lecture


           Previous                                                                                                                       Next