By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,433 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,433 IT Pros & Developers. It's quick & easy.

DOS Window

P: n/a
vj
Hi all,
I am a novice user of C++. I am using Borland c++ builder 5.
When I run a program, a DOS window appears where output of the program
(if intended) is displayed. When the program finishes, this window
closes automatically. I want this window to stay there even after the
program finishes. How can it be done?

Thanks in advance.

Nov 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
vj wrote:
Hi all,
I am a novice user of C++. I am using Borland c++ builder 5.
When I run a program, a DOS window appears where output of the program
(if intended) is displayed. When the program finishes, this window
closes automatically. I want this window to stay there even after the
program finishes. How can it be done?

Thanks in advance.


adding something like getch() or getchar() or system("PAUSE") as the
last statement in "main()" should work.

Nov 22 '05 #2

P: n/a
Neelesh Bodas wrote:
adding something like getch() or getchar() or system("PAUSE") as the
last statement in "main()" should work.


And since this won't work if you call the exit() function, you might want to
take a look at atexit(), although this is C specific... Do we talk about
cstdlib stuff here? :) I never know...

Arne

--
[--- PGP key FD05BED7 --- http://www.root42.de/ ---]
Nov 22 '05 #3

P: n/a
Arne Schmitz wrote:
Neelesh Bodas wrote:
you might want to take a look at atexit(), although this is C specific...


atexit() is equally good with C++. The standard requires that cstdlib
implement atexit() , abort() and exit().

17.4.1.3 - 13 : "The supplied version of the header <cstdlib> shall
declare at least the functions abort(), atexit(), and exit()"

Nov 22 '05 #4

P: n/a
On 2005-11-17 19:18, vj wrote:
Hi all,
I am a novice user of C++. I am using Borland c++ builder 5.
When I run a program, a DOS window appears where output of the program
(if intended) is displayed. When the program finishes, this window
closes automatically. I want this window to stay there even after the
program finishes. How can it be done?

Thanks in advance.


You might want to consult the documentation, there might be some way to
prevent the window from closing (in Visual Studio you can use Ctrl+F5
instead of just F5). Or you could run your application from the Command
Prompt.

Erik Wikström
--
"I have always wished for my computer to be as easy to use as my
telephone; my wish has come true because I can no longer figure
out how to use my telephone" -- Bjarne Stroustrup
Nov 22 '05 #5

P: n/a
add Readln() at end
"vj" <ee***@nottingham.ac.uk>
??????:11**********************@g44g2000cwa.google groups.com...
Hi all,
I am a novice user of C++. I am using Borland c++ builder 5.
When I run a program, a DOS window appears where output of the program
(if intended) is displayed. When the program finishes, this window
closes automatically. I want this window to stay there even after the
program finishes. How can it be done?

Thanks in advance.

Nov 22 '05 #6

P: n/a
vj
Thankyou for all your suggestions.
If I use the command prompt, what is the command to make an .exe file
from the source code (.cpp file)?

Nov 22 '05 #7

P: n/a
On 18 Nov 2005 23:39:08 -0800, "vj" <ee***@nottingham.ac.uk> wrote:
Thankyou for all your suggestions.
If I use the command prompt, what is the command to make an .exe file
from the source code (.cpp file)?


It's in your compiler manual/documentation. You will need to be able
to read this sort of literature as a programmer.
Nov 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.