|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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.
|
|
#2
|
|||
|
|||
|
I think a lot of people use an input prompt to keep the screen from disappearing:
getch(); |
|
#3
|
|||
|
|||
|
i use the system("pause") from the windows.h header file to pause it till a key is pressed
|
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
>> 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 |
|
#6
|
||||
|
||||
|
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.
|
|
#7
|
|||
|
|||
|
"...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. |
|
#8
|
||||
|
||||
|
Quote:
-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() ! ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > console app question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|