0
1.9kviews
Discuss file I/O in C language with different library functions

Mumbai University > Computer Engineering > Sem 3 > Data Structures

Marks: 10M

Year: May 2016

1 Answer
1
13views
  1. The treatment of files in C is very simple, unlike that of other programming languages which have special built-in and often rigid file structures and file handling routines.
  2. C treats file input-output in almost the same way as input-output from/to the console, and provides file input-output functions, very similar to those for input-output from/to the console.
  3. Unlike other programming languages C does not distinguish between sequential and random access (direct access) data files.
  4. The Turbo C provides two different ways of file processing. These are (i) Standard Input/output (stream I/O or high-level I/O). (ii) System-oriented Input/output (low-level I/O).
  5. We can perform most of the tasks by either of these, still there are many important differences between these two. The major differences are given below :
  6. The Standard 1/0 is very simple and most commonly used way of performing file I/O in C language. It provides a wide variety of commands.
  7. The I/O operations, such as buffering, data conversions etc. take place automatically. It will be the only system for I/O if the C version has only one system for I/O. The data is written as individual characters or as strings or as formatted data Library functions are available for transfer of information.
  8. Unformatted data files, organize data into blocks having contiguous bytes of information for more complex data structures such as structures and arrays. Library functions are available that can transfer entire structures or arrays to or from data files.
  9. The System-oriented 1/0 reads and writes the data to/from files the same way as MS-DOS. The data cannot be written as individual characters, or as strings, or as formatted data. Using this approach the data can be written as a buffer full of bytes.
  10. The programmer must set up the buffer for the data, place the appropriate data into it before writing, and take it out from the buffer after reading.
  11. It is harder to program than standard I/O but efficient both in terms of operation and the amount of memory used by the program. Figure 14 shows the detailed classification of file I/O functions :

enter image description here

Please log in to add an answer.