O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Redirection and Files

Input and output involve functions, data, and devices. Consider, for instance, the echo_eof.c program. It uses the input function getchar(). The input device (we have assumed) is a keyboard, and the input data stream consists of individual characters. Suppose you want to keep the same input function and the same kind of data, but want to change where the program looks for data. A good question to ask is, “How does a program know where to look for its input?”

By default, a C program using the standard I/O package looks to the standard input as its source for input. This is the stream identified earlier as stdin. It is whatever has been set up as the usual way for reading data into the computer. It could be an old-fashioned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required