DOS Window

V

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.
 
N

Neelesh Bodas

vj said:
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.
 
A

Arne Schmitz

Neelesh said:
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
 
N

Neelesh Bodas

Arne said:
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()"
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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
 
V

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)?
 
W

W Marsh

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top