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

how stop console application in Borland C++

P: n/a
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..
Jul 22 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a

"PHP2" <gp@nospm.hr> wrote in message news:bp**********@ls219.htnet.hr...
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
Jul 22 '05 #2

P: n/a
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

"Allan Bruce" <al*****@TAKEAWAYf2s.com> wrote in message
news:bp**********@news.freedom2surf.net...

"PHP2" <gp@nospm.hr> wrote in message news:bp**********@ls219.htnet.hr...
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

Jul 22 '05 #3

P: n/a

"PHP2" <gp@nospm.hr> wrote in message news:bp**********@ls219.htnet.hr...
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
Jul 22 '05 #4

P: n/a
thanks!
:-))

"Allan Bruce" <al*****@TAKEAWAYf2s.com> wrote in message
news:bp**********@news.freedom2surf.net...

"PHP2" <gp@nospm.hr> wrote in message news:bp**********@ls219.htnet.hr...
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

Jul 22 '05 #5

P: n/a
PHP2 wrote:
I am try :

// my first program in C++

#include <iostream.h>
#include <iostream> // this is the standard header, not iostream.h
#include <cstdlib> // declares system()
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.

Jul 22 '05 #6

P: n/a
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
Jul 22 '05 #7

P: n/a
jbruno4000 wrote:
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

Jul 22 '05 #8

P: n/a
Why does it need to be portable? It's a temporary measure. Once the application
is completed, the pause statements get removed!
Jul 22 '05 #9

P: n/a
i see what you meant by portable, no need to #include another header. It's a
better way for sure!
Jul 22 '05 #10

P: n/a
"PHP2" <gp@nospm.hr> writes:
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

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com
Jul 22 '05 #11

P: n/a
"Allan Bruce" <al*****@TAKEAWAYf2s.com> wrote in message news:<bp**********@news.freedom2surf.net>...
"PHP2" <gp@nospm.hr> wrote in message news:bp**********@ls219.htnet.hr...
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.


Another alternative is to use
cin.get();

It's a little faster to type, and portable...
Jul 22 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.