C files handling I/O

Drawbacks of Traditional I/O System

  1. Until now we are using Console Oriented I/O functions.
  2. “Console Application” means an application that has a text-based interface. (black screen window))
  3. Most applications require a large amount of data , if this data is entered through console then it will be quite time consuming task
  4. Main drawback of using Traditional I/O :- data is temporary (and will not be available during re-execution )

Consider example –

  1. We have written C Program to accept person detail from user and we are going to print these details back to the screen.
  2. Now consider another scenario , suppose we want to print same data that we have entered previously.
  3. We cannot save data which was entered on the console before.
  4. 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 :

  1. New way of dealing with data is file handling.
  2. Data is stored onto the disk and can be retrieve whenever require.
  3. Output of the program may be stored onto the disk
  4. In C we have many functions that deals with file handling
  5. A file is a collection of bytes stored on a secondary storage device (generally a disk)
  6. Collection of byte may be interpreted as
    • Single character
    • Single Word
    • Single Line
    • Complete¬†Structure.

[divider top=”1″]