www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - How do i pause a console program after execution?

↑ ↓ ← Burner <Burner_member pathlink.com> writes:
hi,

i am using Digital Mars C++ compiler for my learning purposes.
can anyone tell me how to pause the programs i create after execution? coz they
seem to disappear in WinXP immediately after execution.

like in Blood Shed Dev C++ we can use system("PAUSE");
and in turbo c++ getch();

thanx

-burner out
Feb 08 2004
"Matthew" <matthew.hat stlsoft.dot.org> writes:
You need to run them from the command-line.

FYI, if you want to run a command-line program from the shell, you should
put it in a batch file, and call a pause function afterwards, as in:

    rem This batch file calls MyProg and then calls MyPause, so that it the
output from MyProg remains visible in the command box
    MyProg
    MyPause

as to what MyPause is, you have two options:

1. Use the Win32 "pause" utility, which waits until a key is pressed.
2. If you want it to pause for a specific time and then disappear without
requiring a key press, you can use the SyPause utility from
http://synesis.com.au/r_systools.html


"Burner" <Burner_member pathlink.com> wrote in message
news:c05u67$1ot3$1 digitaldaemon.com...
 hi,

 i am using Digital Mars C++ compiler for my learning purposes.
 can anyone tell me how to pause the programs i create after execution? coz

 seem to disappear in WinXP immediately after execution.

 like in Blood Shed Dev C++ we can use system("PAUSE");
 and in turbo c++ getch();

 thanx

 -burner out

Feb 08 2004
↑ ↓ → Scott Michel <scottm mordred.cs.ucla.edu> writes:
Matthew <matthew.hat stlsoft.dot.org> wrote:
 You need to run them from the command-line.

Much relief that provides when run from the IDDE debugger. The best bet is still to invoke getchar(), fgetc(stdin), getc(stdin), etc. if running from the IDDE debugger. -scooter
Feb 08 2004
→ "KTC" <me here.com> writes:
"Burner" wrote...

 like in Blood Shed Dev C++ we can use system("PAUSE");
 and in turbo c++ getch();

If you don't mind it being specific to windows, then you could still use system("PAUSE"); (Part of #include <cstdlib> ) Otherwise, you can of course write your own pause function kinda thing ... void pause() { std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max()); // Clear whatever's still in the buffer std::cout << "Press Enter to continue . . .\n"; std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); }
Feb 10 2004