C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #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: 199 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 7 sec
Reputation Power: 11
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
MySpace
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 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,401 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 8 h 41 m 14 sec
Reputation Power: 4080
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: 199 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 7 sec
Reputation Power: 11
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
MySpace
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 God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,249 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 17 h 27 m 51 sec
Reputation Power: 1985
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: 199 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 7 sec
Reputation Power: 11
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
MySpace
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: 11
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: 199 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 7 sec
Reputation Power: 11
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
MySpace
....

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: 199 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 7 sec
Reputation Power: 11
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
MySpace
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: 11
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: 199 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 7 sec
Reputation Power: 11
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
MySpace
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

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap