SunQuest
           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 May 1st, 2003, 09:13 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
console app question

damn i feel like a dumbass, i havent made a console app in probably 4 or 5 months, and i forgot the reason why when i run a console app directly from the .exe outside of MSVC++, it closes automatically.

Reply With Quote
  #2  
Old May 1st, 2003, 10:21 PM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
I think a lot of people use an input prompt to keep the screen from disappearing:

getch();

Reply With Quote
  #3  
Old May 1st, 2003, 11:54 PM
airswit airswit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 19 airswit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i use the system("pause") from the windows.h header file to pause it till a key is pressed

Reply With Quote
  #4  
Old May 2nd, 2003, 09:30 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 57 m 9 sec
Reputation Power: 437
Stupid question: How are you running it?

Normal way:
1. Open a DOS window (usually the first thing I open up after booting.
2. cd to the EXE's directory (assuming that that directory is not in the PATH -- eg, all my utilities are in C:\UTIL which is in the search path, so I can run them from anywhere).
3. Run the program from the command line.

For the life of me, I cannot understand how running the program could cause the DOS window to close.

Now, we have encountered that problem when we would invoke a DOS command from within a Windows app; eg, adding grep to the Tools menu in VC++1.52. In that case, we had to wrapper grep within a batch file that paused after running grep, or else the window would close on us immediately. GREP.BAT looks like this:
Code:
c:\util\grep.exe -n %1 %2 | more
pause



EDITED 2003 May 02, 1635 PDT:
Honest, guys, I'm not trying to be a curmudgeonous old DOS'r (if for no other reason than I don't need to try), but it would just never occur to me to run a console app any way other than from DOS. Yes, I'll launch Windows apps through Windows Explorer or Run, but never a console app.

------------------------------------------------
DOS? Was ist DOS?

Last edited by dwise1_aol : May 2nd, 2003 at 06:44 PM.

Reply With Quote
  #5  
Old May 2nd, 2003, 11:03 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 55 m 33 sec
Reputation Power: 797
>> Stupid question: How are you running it?
I'm guessing that he's navigating to the directory in Windoze explorer and double clicking on the exe.

Alternatively, he could also be using using Start-->Run

Either way, after the program is done, it will return control back to the program that spawned it, (i.e.) Windows Explorer. Windows will then close the console window, since the program is no longer running.

If you open a DOS window and follow dwise_aol's instructions, then when the program is done, it returns control back to the program that spawned it (i.e.) the DOS window. That's why your DOS window will still stay open on the screen

Reply With Quote
  #6  
Old May 2nd, 2003, 12:05 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
yea i was running it from explorer. if i run it from dos prompt it's not a problem, it just returns control back to dos. i got it fixed now, thanks.

Reply With Quote
  #7  
Old May 2nd, 2003, 09:41 PM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
"...i forgot the reason why when i run a console app directly from the .exe outside of MSVC++, it closes automatically."

Ahhh...the "why" is what you were after. Sorry.

Reply With Quote
  #8  
Old May 2nd, 2003, 09:48 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
Quote:
Originally posted by 7stud
"...i forgot the reason why when i run a console app directly from the .exe outside of MSVC++, it closes automatically."

Ahhh...the "why" is what you were after. Sorry.


-nope u were right! i was looking for both actually, the why and the how to fix this. i ended up scrounging some old code from last year's class, and i found that i used, guess what: cin.get() !

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > console app question


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 5 hosted by Hostway