Input and output
|
#include <stdio.h> |
The shell sets up three standard I/O streams when
you run a program:
stdin -- the standard input, stdout
-- the standard output, and
stderr -- the standard error output. Normally
stdin is your key
-board, stdout is your screen, and
stderr is also your screen, but this
can be changed using pipes and redirection.
The first argument to fprintf is a stream.
The arguments to scanf must be pointers.
scanf("%d", age); will cause a mysterious runtime
error.
|
/* copy input to output */ |
getchar() returns an int, not a
char. This allows it to return a flag
value EOF when you try to read past the end of the
file.
EOF is defined in stdio.h.
To produce EOF from your keyboard, type control-D.