Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Standard Output and Standard Input

4/16/12

Getting information in and out of a computer is the most important thing that a program can do. Without input and output computers would be quite useless.

4/16/12

C treats all its output as though it were reading or writing to different files. A file is really just an abstraction: a place where information comes from or can be sent to. Some files can only be read, some can only be written to, others can be both read from and written to. In other situations files are called I/O streams.
4/16/12

C has three files (also called streams) which are always open and ready for use. They are called stdin, stdout and stderr, meaning standard input and standard output and standard error file.
4/16/12

Stdin is the input which usually arrives from the keyboard of a computer. Stdout is usually the screen. Stderr is the route by which all error messages pass: usually the screen. This is only `usually' because the 4/16/12

In fact what happens is that these files are just handed over to the local operating system to deal with and it chooses what to do with them. Usually this means the keyboard and the screen, but it can also be redirected to a printer or to a disk file or to a modem etc.. depending upon how the user ran the program.
4/16/12

4/16/12

The keyboard and screen are referred to as the standard input/output files because this is what most people use, most of the time. Also the programmer never has to open or close these, because C does it automatically. The C library functions covered by stdio.h provides some methods for working with stdin and stdout. 4/16/12

They are simplified versions of the functions that can be used on any kind of file printf () scanf () getchar() putchar()
4/16/12

They are:

You might also like