Next: Basic I/O Up: Predefined Streams Previous: Predefined Streams


This how we override the UNIX default predefined I/O defaults.

This is not part of C but operating system dependent. We will do redirection from the command line.

> - redirect stdout to a file.

So if we have a program, out, that usually prints to the screen then

out > file1

will send the output to a file, file1.

< - redirect stdin from a file to a program.

So if we are expecting input from the keyboard for a program, in we can read similar input from a file

in < file2.

| - pipe: puts stdout from one program to stdin of another

prog1 | prog2

e.g. Sent output (usually to console) of a program direct to printer:

out | lpr
Fri May 20 13:40:49 BST 1994