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

Started by
9 comments, last by mx1 22 years, 3 months ago
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
Advertisement
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.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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.
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.


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.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
  #include <stdlib.h>int main(){    system("PAUSE");    return 0;}  

Maybe you wanna try this:
  #include <cstdio>void main(...){   .   .   .  getch();}  

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
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.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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;

This topic is closed to new replies.

Advertisement