Basic I/O

C manages input and output to a program using streams. A stream contains sequence of data that flows between the program and the source/destination. The source / destination can be file or devices such as keyboard and screen.

There are three I/O streams in C for standard input and output functionality. An input stream is used to read data, output stream is used to write data and error stream is used to write the error messages. Usually an input stream is linked to the keyboard and Output and Error streams are linked to the screen.

  • Input stream is called stdin (for standard input)
  • Output stream is called stdout (for standard out)
  • Error stream is called stderr (for standard error)

C provides functions to read and write data, to and from these standard I/O streams. These functions are in the library stdio.h. This library needs to be included in the program before it can be called.

The most important functions in this library are:

  • printf()
  • scanf()
  • getchar()
  • putchar()

Post a comment


Your Comment

Email (We dont publish it)


Nothing the first to share wisdom.