Microsoft KB Archive/70786

INF: I/O Redirection Does Not Work Inside the QC Environment PSS ID Number: Q70786 Article last modified on 01-27-1992 PSS database name: S_QuickC

2.00 2.01 2.50 2.51

MS-DOS

Summary:

When working inside the QuickC environment, specifying program redirection to or from a file does not work as expected. If redirection symbols are placed in the Command Line field of the Run/Debug dialog box available from the Options menu, the symbols will be treated as command-line arguments to the current program rather than as DOS redirection operators. This is expected behavior inside the QuickC environment.

More Information:

When running a program from DOS, console input and output (stdin and stdout, respectively) may be redirected using the “<” and “>” symbols on the command line. For example, the command

prog < prog.in > prog.out

will redirect input from the file PROG.IN and output to the file PROG.OUT.

From the QuickC environment, when file redirection is specified, instead of reading or writing to the files specified, the entire string is passed to the program as an argument. For example, assume the following line is entered into the Command Line field of the Run/Debug dialog box:

prog.out

When the program is executed, the C command-line arguments argv[1] and argv[2] will be the strings “prog.out”, respectively. If spaces are placed between the redirection symbol and the file names, then QuickC just assumes that there are four command-line arguments (that is, “<”, “prog.in”, “>”, and “prog.out”).

To perform command-line redirection with your program, you must either exit the QuickC environment or shell out by choosing DOS Shell from the File menu. In either case, you then execute your program by typing in the entire command line, including the desired redirection, at the DOS prompt.

Copyright Microsoft Corporation 1992.