C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 27th, 2003, 08:49 AM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
Program Output

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?

Reply With Quote
  #2  
Old February 27th, 2003, 09:19 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 22 m 8 sec
Reputation Power: 797
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.

Reply With Quote
  #3  
Old February 27th, 2003, 09:21 AM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
I'm runng it on a compiler I have on the system. Anyone know of a C++ compller that does this internally or automaticlly?

Reply With Quote
  #4  
Old February 27th, 2003, 10:04 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,803 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 11 h 40 m 35 sec
Reputation Power: 437
Quote:
Originally posted by Sonic98
I'm runng it on a compiler I have on the system. Anyone know of a C++ compller that does this internally or automaticlly?


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:

Code:
sprintf(s,"%d,%d,%d\n",x,y,z);
write(stdout,s,strlen(s));
write(fd,s,strlen(s));


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.

Reply With Quote
  #5  
Old February 27th, 2003, 12:00 PM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
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?

Reply With Quote
  #6  
Old February 27th, 2003, 03:44 PM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Not sure what your doing exectly but this may help.

compile.bat
Code:
dir drive: 2>a.txt 1>b.txt
type a.txt


This code fails because drive: is not valid so std error will output as dir normally has no output for a valid call.

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!
__________________
--

ngibsonau

Reply With Quote
  #7  
Old February 27th, 2003, 04:43 PM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
....

Last edited by Sonic98 : February 27th, 2003 at 04:45 PM.

Reply With Quote
  #8  
Old February 27th, 2003, 04:46 PM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
Quote:
Originally posted by ngibsonau
Not sure what your doing exectly but this may help.

compile.bat
Code:
dir drive: 2>a.txt 1>b.txt
type a.txt


This code fails because drive: is not valid so std error will output as dir normally has no output for a valid call.

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!


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.

Reply With Quote
  #9  
Old February 27th, 2003, 06:04 PM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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.

Reply With Quote
  #10  
Old February 28th, 2003, 01:54 AM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
Nevermind. I forgot that this is WinXP. I can copy and paste from cmd prompt.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Program Output


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway