Wednesday, November 2, 2011

Types of I/O in C programming language

Though C has no provision for I/O, it of course has to be dealt with at some point or the other. There is not much use writing a program that spends all its time telling itself a secret. Each Operating System has its own facility for inputting and outputting data from and to the files and devices. It’s a simple matter for a system programmer to write a few small programs that would link the C compiler for particular Operating system’s I/O facilities.
The developers of C Compilers do just that. They write several standard I/O functions and put them in libraries. These libraries are available with all C compilers. Whichever C compiler you are using it’s almost certain that you have access to a library of I/O functions.
Do understand that the I/O facilities with different operating systems would be different. Thus, the way one OS displays output on screen may be different than the way another OS does it. For example, the standard library function printf( ) for DOS-based C compiler has been written keeping in mind the way DOS outputs characters to screen. Similarly, the printf( ) function for a Unix-based compiler has been written keeping in mind the way Unix outputs characters to screen. We as programmers do not have to bother about which printf( ) has been written in what manner. We should just use printf( ) and it would take care of the rest of the library functions available for I/O.

There are numerous library functions available for I/O. These can be classified into three broad categories:
(a)  Console I/O functions - Functions to receive input from keyboard and write output to VDU.
(b)  File I/O functions - Functions to perform I/O operations on a floppy disk or hard disk.

In this chapter we would be discussing only Console I/O functions. File I/O functions would be discussed in Chapter 12.

No comments:

Post a Comment