DOS Re-direction

DOS like UNIX supports what is called Re-direction. This is the ability to send output from program to a file. The screen and keyboard in UNIX is treated like a file. Same is true for DOS. What is implies is that programs that normally perform I/O can do it to and from files using > for output and < for input.
Example: consider the following Pascal program called hello.pas:
	Program hello;
	Begin
		writeln('hello world');
	End.
or C program:
	#include <stdio.h>
	main()
	{
		printf("hello world\n");
		return 0;
	}
When run, this program sends hello world to the screen. By making a DOS EXE file (see the particular compiler for exact syntax), you can then shell (or go to DOS), and run program by typing hello (remember type EXIT from the DOS prompt to return to your compiler session).

Now for the re-direction, you can send the output to a file called myoutput.fil by giving the DOS command:

hello > myoutput.fil
Now, the string hello world will be permanently saved in the file called myoutput.fil

You can have your program read from a file by using the < character. The syntax is:

program_name < file_name
Both input and output can be redirected by using both < and >.