Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dos window closing

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Howdy,
I just started using Borland C++, after getting used to Visual C++, and am having trouble. Whenever, I run a program, the dos window opens, and waits for input(cin), but immediately after revieving input closes the window. So there is no time to read the output. I don't know how to keep the window open. In Visual, the window remained open until the user closed it. Any help will be greatly appreciated.
 
A simple solution may be this way:

Before finishing the program insert a input statement and wait for a input like spacebar, cr....
[sig]<p>hnd<br><a href=mailto:hasso55@yahoo.com>hasso55@yahoo.com</a><br><a href= > </a><br> [/sig]
 
Hello,

You could use the function getch() in the dos headerfile conio.h, which usually is what i do.

Example:

Code:
#include <conio.h>

int main(void)
{
...
...
getch();
}

Note that getch() doesn't work on the UNIX-platform.

You could also insert a pause, which you do like this:

Code:
#include <windows.h>

int main(void)
{
...
...
Pause(msec); // miliseconds!
}

Bye,
Emil
---- [sig][/sig]
 
Press Alt F5
and see the results you want
press any key and return to programming...

otherwise

put a pause in your program...
in the ways described above...
or asking for any input you want...

Hope it helps... :)

NJMC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top