Files 463
OUTPUT
TMP=C:WINDOWSTEMP
TEMP=C:WINDOWSTEMP
PROMPT=$p$g
winbootdir=C:WINDOWS
COMSPEC=C:WIN DOWSNCOMMAND.COM
PATH=C:WINDOWS;C:WINDOWSCOMMAND;C:JDK1.2.1BIN;0JDKU2.1;
CMDLINE=WIN
windir=C:WINDOWS
13.12 I/O RE DIRECTION
Consider the dos command d i r > a b c , execute it at dos prompt. Here, d i r is the internal dos
command and abc is the name of the file. Here, instead of displaying list of files and directories on
the screen, it is redirected in a text file abc i.e. the files and directories would be possible to see in
abc file. For this use type abc command at dos prompt.
From the above example the reader can understand that the output of command can be redirected to
another file. Using redirection the output of the program instead of displaying on the screen is stored
on the disk in the form of file. With this we can avoid creating separate functions for writing files to the
disk or to the printer. Thus, this is an advantage and is a convenient approach for writing files to the
disk. Using this redirection concept both read and writes operations are possible.
13.43 Write a program to read character from keyboard till user presses enter.
# in clu d e < std io .h >
# in clud e <conio.h>
void mainO
c
char c;
while ((c=g etc(std in))l= fn f)
putdCrStdout);
I
123456789
Explanation On compiling this program we would get an executable file r e a d . exe. Execute this
program on the dos prompt as given below.
C> rea d .e xe > in p u t.tx t
Now, whatever data is inputted is redirected to text file inpu t. txt. To confirm, type the file using type
command. The output would be
123456789