|
From: Luigi S. <gi...@li...> - 2003-05-26 10:12:57
|
On Sun, May 25, 2003 at 04:45:08PM -0400, Jeffrey Hall wrote:
> [...]
> In short, I can't scroll back in the DOS window to mark (select) the
> beginning of a file that's more than circa 24 lines long and then save the
> file.
Hi Jeff,
As your program prints its output to the stdout stream, you could redirect
this latter stream to a file, so that output will be saved and available to
be examined later.
To redirect stdout, you should run your program from the Dos command
line, using the following syntax (assuming "fib.exe" is the name of the
program and "fib.out" the name of the file where you wish to store output)
fib > fib.out
Also, if you want to have the output of two runs stored in the same file,
you may "redirect and append", that is, after the above command use the
following one:
fib >> fib.out
To tell apart output of the two runs, I suggest printing something at
the end of the run, that could be as simple as a couple of '\n' characters.
Finally, in case your program gets input from the stdin stream, you may
save some typing by creating a file with your input and feeding it to the
program by the command (assuming "fib.inp" is the file storing input)
fib < fib.inp
Of course stdin and stdout may be redirected at the same time.
> [...]
> getch();
> return 0;
> }
>
NOTE: the above "getch()" is not required when the program is to be
used from a Dos window (as I think it should be always done when the
program is a console application). IMHO, using such instruction is
bad practice, in fact, a potential user could run the program from the
console and use redirection, not getting the prompt back (because of
the program waiting for the extra input character needed by the non-portable
"getch" instruction) he could think that execution got trapped in some
infinite loop (especially if the program deals with math ;-) and then
just kill the application by closing the Dos window.
--
>> gisan >>
|