Archived

This topic is now archived and is closed to further replies.

mx1

How do I stop Win2k from automatically closing the command prompt after the program

Recommended Posts

mx1    122
finishes? If I write a little program Like the Hello World program or something the command prompt wont stay open, it closes automatically, about a split second after it opened. I would rather manually close it when im ready. I searched through the Win2k help file to no avail. Please help. Edited by - mx1 on January 16, 2002 4:12:17 AM

Share this post


Link to post
Share on other sites
Arild Fines    968
Either run the app directly from the command line, or put something like int a; cin >> a; at the end of the program.

Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.

Share this post


Link to post
Share on other sites
mx1    122
Well for some reason it wont let me run it directly from the command line I get this.

C:\>Project 1
''Project'' is not recognized as an internal or external command,
operable program or batch file.

C:\>


And I tried that.
int a; cin >> a;
and it didn''t work either.

I am using WIN2k and DEV C++.
Any help is appreciated.

Share this post


Link to post
Share on other sites
mx1    122
Ok I figured it out.
for some reason it would not run named Project 1, I had to rename it.
Maybe it does not accept spaces, that is probably why I got,

''Project'' is not recognized as an internal or external command,
operable program or batch file.

that error.
Thanks for the help.


Share this post


Link to post
Share on other sites
Arild Fines    968
If you have stuff with spaces at the command line, you have to put it in quotes, eg:
  
C:\MyProjects\>"Project 1"

would probably work. In practice though, most people ensure their exes dont have any spaces in them.

Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Maybe you wanna try this:
  
#include <cstdio>
void main(...){
.
.
.
getch();

}

Share this post


Link to post
Share on other sites
core    106
When maneuvering in DOS, sometimes it helps to do a dir /X for a directory listing. The /X switch will cause the directory list to appear in the old DOS 8.3 naming convention. So if you're trying to switch to a directory entitled "Project 1", you would type cd projec~1. If the directory name is 8 characters long or less, you can type the whole name. Otherwise you must take the first SIX characters of the name and concatenate a ~1 to the end.

As for keeping your console (DOS) window from closing prematurely, use the getch() function at the end of your program.

"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

Edited by - core on January 17, 2002 1:44:02 PM

Share this post


Link to post
Share on other sites
Arild Fines    968
quote:
Original post by core
When maneuvering in DOS, sometimes it helps to do a dir /X for a directory listing. The /X switch will cause the directory list to appear in the old DOS 8.3 naming convention.


He said Win2K - Win2K doesnt use command.com(its supplied, tho - if you are feeling extremely masochistic one day).



Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
cin >> a; should work, but you may have to clear the buffer first. for some reason cin leaves the carriage return in the buffer a lot (almost always). you might be able to get away with cin >> a; cin >> a;

Share this post


Link to post
Share on other sites
core    106
That''s what I get for not paying attention. Oh well, it''s still semi-useful to us masochists.

"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

Share this post


Link to post
Share on other sites