|Usually used to view data on the||Usually used to print data on the|
|Data cannot be formatted||Data can be formatted|
|Data in the tables can be modified||Data cannot be modified|
|New data can be entered||New data cannot be entered|
DATA FILES AND THEIR IMPORTANCE:
- Sometime computer program need large amount of input data. So it is very difficult to enter all data at run time.
- Input data is stored in a file on the disk. Computer program reads the data from the data disk.
- Similarly, programs are also often produce large output which is not possible to view the entire data on screen at run time.
- The output from a program is written into a data file and is stored on the disk.
ACCESS METHOD OF FILES:
- Sequential Access Files (Data read and write in a sequence. If we want to read 5th record then the first four records have to be read. Text Data Files are Sequential Access Files in C Language).
- Random Access Files (Read and write data directly. If we want to read 5th record then we can read required record directly. Binary Data Files are Random or Direct Access Files in C Language).
File Access Modes:
|a||Append Mode. Data can be added at the end of file.|
|r+||Reading / Writing Mode.|
|w+||Writing / Reading Mode.|
|a+||Reading / Append Mode.|
- “fopen” function is used to open a file.
- Before opening a file, a file pointer is associated with it.
- Example FILE *fp; fp=fopen(“abc.txt”,”w”);