10. File



 Files is a set of records that can be accessed through the set of library functions .

Applications generally involve tremendous amount of data to be read and written to an auxiliary storage.hence to save such information on the disk we use data files. 


Files is a collection of numbers ,symbols ,&text placed on the disk.


FILE TYPE ::


  1. Sequential file : in this type datas are kept sequentially .If we want to read the last record of the file we need to read all the records before that record.


  1. Random Access file : in this type data can be read and modified randomly . in this type if we want to read the last records of the file ,we can read it directly .it takes less time as compared to a sequential file.


STEPS FOR FILE OPERATORS ::


  1. Openings of file

  2. Readings or writing file 

  3. Closing file 


FILE FUNCTION :


Function                      Operation 

 

fopen()                 -        creates a new file for read /write operation.


fclose()                 -        closes a file associated with file pointer.


fgetc()                   -       Reads the character from current pointer position and advances the                                         pointer to next character.


getc()                    -        same as fgets ()


fprintf()                   -       writes all the types of data values to the file.


fscanf()                  -      Reads all the types of data values to the file.


putc()                    -     writes character one by one to a file.


Fputc ()                  -    same as puts ().


Gets ()                   -       reads string from the file 


Puts ()                   -       writes string to the file 


putw()                    -      writes an integer to the file 


getw()                   -     reads an integer from the file 


fread()                  -    reads structured data written by the fwrite () function.


Rename ()             -    changes the name of the file 


Perror ()                 -     print compilers error messages along with users defined message 


Post a Comment

Previous Post Next Post