File handling - STUDY NOTES

Post Top Ad

File handling




It is most important and useful concept for any programming language because it provides the facility to store the data permanently in secondary memory. In case of file handling the program supports the facility to create a separate space in secondary memory by a particular name.

“C” supports a “FILE” data type for file handling.

C supports a set of pre defined function for the file handling as follows: -

     a.     fopen()
     b.     fclose()
     c.      getc()
     d.     putc()
     e.     getw()
     f.       putw()
     g.     fgets()
     h.     fputs()
     i.        fprintf()
     j.       fscanf()
     k.     fseek()
     l.        ftell()
     m.  rewind()
etc.

     a.     fopen(): -      It is used to create a new file or open an existing file.

     b.     fclose(): -      The opened file can be closed to change its mode.

     c.      getc() and putc() function: -      getc() function is used to read data character by character from file.

       The putc() function is used to write data character into file.

     d.     getw() and putw(): -      getw() function is used to read one integer data at a time from file.

        putw() function is used to write one integer at a time into the file.

     e.     fgets() and fputs():-      fgets() function is used to read one string at a time from file.

        fputs() function is used to write one string at a time into file.

     f.       fprintf() and fscanf() function: -                                                                                  
               fprintf():-      It is used to write a set of data at a time into a file. The set of data may be homogenous and hetrogenous.

fscanf():-       It is used to read a set of data at a time from a file.


     g.     fseek(), ftell() and rewind() function: -       These 3 function are used for random access file handling, the movement of file pointer within file without closing is called as random access file.

a.     fseek(): -       It is used to move the file pointer within file either in read mode or write mode both.

b.     ftell():-         It represents the current position of the file pointer it is measured in byte.

c.      rewind(): -        It sets the file pointer at the beginning of file.



for detailed information download PDF


downloading servers are below


server 1 [media fire]

No comments:

Post a Comment

Post Bottom Ad