how stop console application in Borland C++

P

PHP2

how stop console application in Borland C++ that stay on top more time?

when I start console aplication, console stay on top 1 seconds only..
 
A

Allan Bruce

PHP2 said:
how stop console application in Borland C++ that stay on top more time?

when I start console aplication, console stay on top 1 seconds only..

If I understand you correctly then

system("pause");

may be what you are after. This will make the 'console' appear until the
user presses a key. I think this works only in windows which I am guessing
is what you are after.
If this is not what you require, then perhaps a better description is
required.
Allan
 
P

PHP2

I am try :

// my first program in C++

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
system("pause");
}


but this was NOT pause command prompt window in win2000
 
A

Allan Bruce

PHP2 said:
I am try :

// my first program in C++

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
system("pause");
}


but this was NOT pause command prompt window in win2000

you need to place the
system("pause");
before the
return 0;
I will leave it up to you to research it as to why this is the case.
Allan
 
P

PHP2

thanks!
:))

Allan Bruce said:
you need to place the
system("pause");
before the
return 0;
I will leave it up to you to research it as to why this is the case.
Allan
 
D

Dirk Feytons

PHP2 said:
I am try :

// my first program in C++

#include <iostream.h>

#include <iostream> // this is the standard header, not iostream.h
#include said:
int main ()
{
cout << "Hello World!";

// cout lives in the std namespace
std::cout << "Hello World!";
return 0;
system("pause");

// system() lives in the std namespace
std::system("pause");
return 0;

--
Dirk

(PGP keyID: 0x448BC5DD - http://www.gnupg.org - http://www.pgp.com)

..oO° For sale: hand scanner. Used twice. °Oo.
 
J

jbruno4000

Alternatively, why not use getch() ?

#include <iostream.h>
#include <conio> // for getch()

int main ()
{
cout << "Hello World!";
getch();
return 0;
}

getch() causes the program to freeze until you press any key on the keyboard.
I've always found it a great testing tool especially within loops but do remove
them once you're satisfied with the program.

JB
 
T

Thomas Matthews

jbruno4000 said:
Alternatively, why not use getch() ?

#include <iostream.h>
#include <conio> // for getch()

int main ()
{
cout << "Hello World!";
getch();
return 0;
}

getch() causes the program to freeze until you press any key on the keyboard.
I've always found it a great testing tool especially within loops but do remove
them once you're satisfied with the program.

JB

Alternatively, why not something more portable:
#include <iostream>
using namespace std;

int main(void)
{
cout << "Did you read this?\n";
cin.ignore(100000, '\n'); // Wait for the Enter key
return 0;
}


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
J

Jupiter5F

Why does it need to be portable? It's a temporary measure. Once the application
is completed, the pause statements get removed!
 
J

jbruno4000

i see what you meant by portable, no need to #include another header. It's a
better way for sure!
 
F

Frank Schmitt

PHP2 said:
I am try :

// my first program in C++

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
system("pause");
}


but this was NOT pause command prompt window in win2000

Perhaps you should place the system("pause") *before* return 0 :)

HTH & kind regards
frank
 
J

J. Campbell

Allan Bruce said:
If I understand you correctly then

system("pause");

may be what you are after. This will make the 'console' appear until the
user presses a key. I think this works only in windows which I am guessing
is what you are after.

Another alternative is to use
cin.get();

It's a little faster to type, and portable...
 

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
474,147
Messages
2,570,835
Members
47,383
Latest member
EzraGiffor

Latest Threads

Top