C files handling I/OPritesh
Drawbacks of Traditional I/O System
- Until now we are using Console Oriented I/O functions.
- “Console Application” means an application that has a text-based interface. (black screen window))
- Most applications require a large amount of data , if this data is entered through console then it will be quite time consuming task
- Main drawback of using Traditional I/O :- data is temporary (and will not be available during re-execution )
Consider example –
- We have written C Program to accept person detail from user and we are going to print these details back to the screen.
- Now consider another scenario , suppose we want to print same data that we have entered previously.
- We cannot save data which was entered on the console before.
- Now we are storing data entered (during first run) into text file and when we need this data back (during 2nd run) , we are going to read file.
Introduction to file handling in C :
- New way of dealing with data is file handling.
- Data is stored onto the disk and can be retrieve whenever require.
- Output of the program may be stored onto the disk
- In C we have many functions that deals with file handling
- A file is a collection of bytes stored on a secondary storage device (generally a disk)
- Collection of byte may be interpreted as –
- Single character
- Single Word
- Single Line
- Complete Structure.