February 27th, 2003, 08:49 AM
Is there a way to store my output into a file, so that I can look over it later yet still see the output on the screen as I'm running the program?
February 27th, 2003, 09:19 AM
If you're running this on a *nix system, then the easiest way would be to simply pipe your output through the tee command. man tee for more info.
February 27th, 2003, 09:21 AM
I'm runng it on a compiler I have on the system. Anyone know of a C++ compller that does this internally or automaticlly?
February 27th, 2003, 10:04 AM
What comes immeditately to mind is to use pairs of print commands: one to the screen and the other to a file. This might be streamlined a bit if you were to use sprintf() to create the output string and the print the string to both destinations; eg:
Or using the higher-level printf() and fprintf() functions.
You didn't say whether you are using a UNIX/Linux system or DOS, nor which compiler you are using. That would give us a better idea of what tools or techniques would be available to you.
February 27th, 2003, 12:00 PM
I'm am compiling locally on a Windows XP. I am using the Dev C++ compiler from Bloodshed. It compiles the program then runs the exe at the command prompt. IS there another compiler with a better executing/debugging method out there?
February 27th, 2003, 03:44 PM
Not sure what your doing exectly but this may help.
This code fails because drive: is not valid so std error will output as dir normally has no output for a valid call.
dir drive: 2>a.txt 1>b.txt
stderr ie filehandle 2 will be redirected to the file a.txt and stdout ie filehandle 1 will be redirected to b.txt
You can then just type the output of the file to the screen!
February 27th, 2003, 04:43 PM
Last edited by Sonic98; February 27th, 2003 at 04:45 PM.
February 27th, 2003, 04:46 PM
The program I am using is a C++ editor and compiler. When I tell it to compile a program, it creates an exe if there is no error. Then win you click debug, it runs the exe. The way it runs the exe is no different than going to the command/dos prompt and running the exe. In other words it runs it in a DOS window. The only way I've been able to print the out is to do a file.exe>file.txt. But if I do it this way, I don't see the output on the screen, but everything does show up in the text file.
February 27th, 2003, 06:04 PM
As long as you don't have a long running compile and you don't care if you don't see all the errors in real time just use a batch file that has "type file.txt" after the line that compiles.
As long as your OS allows redirection of stderror also you should have no problems. (But you've already though of that?)
I think MS DOS 5 and 6 you can anly redirect stdout. But NT and 2000 seem to redirect stderr fine.
February 28th, 2003, 01:54 AM
Nevermind. I forgot that this is WinXP. I can copy and paste from cmd prompt.