Friday, 30 March 2012

File Handling


File Handling

è    The process of accessing a file from memory is known as file handling.
è    File handling is also known as File Input/Output(I/O).
è    File handling process includes following operations.
1.     Naming a file. 
2.     Opening a file
3.     Reading data from a file.
4.     Writing data a file.
5.     Closing a file.
è    To access any file need to declare a pointer to FILE structure and then associate it with the particular file. This pointer is referred as a file pointer and declared  as follow:
                                      FILE *ptr_var_name;

File Structure

To store data in a file in the secondary memory , need to specify certain things about the file , to the operating system. They include :
1.                                                                       File name
2.                                                                       Data structure
3.                                                                       Purpose

Here,
File name is a string of characters that make up a valid filename for the operating system. It contains two parts , a primary name and an optional period with extension

Ex,  xyz.txt
      Digit.c
      Name

Data structure of a file is defined as FILE in the library of standard I/O function definitions. Therefore , all files should be declared as type FILE before they are used . FILE is a defined data type.

Purpose specifies that for which use file is opening , such as for reading, writing , appending etc .

Posted By : Ruchita Pandya

No comments:

Post a Comment