Updated: 2003-01-19 05:50

Creating a DOS executable

Last revised: Sunday January 19, 2003 05:50.

Students often find it convenient to be able to redirect the input and output streams of their programs using the redirection operators available on a DOS command line, e.g.:

C:\> LAB1 >out.txt
C:\> LAB2 <input.txt >out.txt
C:\> LAB3 argument1 argument2 >out.txt

This is a very convenient way to supply different test files to your program, and to save the output for later editing and printing.  If you want to test the effect on your program of input lines longer than the Windows limit of 511 characters, or the DOS limit of 127 characters, you must redirect input from a file containing the long lines you wish to try.

This file explains how to make this work.

Turbo C version 3

Turbo C always creates DOS executable files.  You don't need to do anything special.  The resulting programs will correctly handle redirection on the DOS command line.

Borland C versions 4.x and 5.x

By default, the more recent versions of Borland C create "Windows" C programs that ignore redirection when started from DOS command lines.  To build a DOS executable, you need to do this:

  1. Create a new Project.
  2. When presented with options for the new project, select the Application (.exe) type and the "DOS standard" sub-type using the drop-down list boxes.
  3. When the project is created, import your C program source and build it.  The resulting *.exe file can be run from a DOS prompt and will handle redirection.

Problems

Apparenly the better features of the Borland debuggers are not available when you build a DOS executable.  You may find it best to debug your files in the Windows environment, and only build the DOS executable when it comes to the final input/output testing phase.

Last revised: Thursday January 15, 1998 01:29.

Web Author: Ian! D. Allen idallen@idallen.ca      Updated: 2003-01-19 05:50

Internet Free Zone Level 1 logo Support free and non-commercial Internet.

Any Browser logo This site works best in Any Browser, a campaign for non-specific WWW.

Creative Commons License logo This work is licensed under a Creative Commons License.