Board index » cppbuilder » Dos window closes too fast..

Dos window closes too fast..

Steven, you are in the wrong (!) newsgroup!

Anyway - here is one way of resolving your problem:
Include a getch(); statement at the end of your main() function (before the
"return" statement, if you use one).
getch() waits for single character input - thus your DOS session will not
terminate until you press any key...
You will need to   #include <conio.h>   to use getch().
You might want to add a    cout <<"Press any key to continue";   in the line
that precedes getch() ;
(In that case don't forget to   #include <iostream>   and specify standard
namespace:   using namespace std;   after your header files)

Johannes, Harrow, UK

Here is the code snippet:

#include <iostream>  // include this header to use the cout stream
#include <conio.h>    // include this header to use: getch();
using namespace std;  // include this line if you are using <iosteam>

int main()
{
...

/* Add getch() at the end of your main() function, just before your return
statement - getch() waits for a  single character input  */
/* N.B getch() is commonly used when single character input is required e.g.
user input at a MENU:  e.g   char ch = getch();    */

   cout << "Press any key to continue";
   getch();
   return 0;

Quote
}
----- Original Message -----
From: <ss_nospam@no___spam_spam.com>

Newsgroups: borland.public.cppbuilder.graphics
Sent: Friday, February 02, 2001 7:33 PM
Subject: Dos window closes too fast..

 

Re:Dos window closes too fast..


Steven, you are in the wrong (!) newsgroup!

Anyway - here is one way of resolving your problem:
Include a getch(); statement at the end of your main() function (before the
"return" statement, if you use one).
getch() waits for single character input - thus your DOS session will not
terminate until you press any key...
You will need to   #include <conio.h>   to use getch().
You might want to add a    cout <<"Press any key to continue";   in the line
that precedes getch() ;
(In that case don't forget to   #include <iostream>   and specify standard
namespace:   using namespace std;   after your header files)

Johannes, Harrow, UK

Here is the code snippet:

#include <iostream>  // include this header to use the cout stream
#include <conio.h>    // include this header to use: getch();
using namespace std;  // include this line if you are using <iosteam>

int main()
{
...

/* Add getch() at the end of your main() function, just before your return
statement - getch() waits for a  single character input  */
/* N.B getch() is commonly used when single character input is required e.g.
user input at a MENU:  e.g   char ch = getch();    */

   cout << "Press any key to continue";
   getch();
   return 0;

Quote
}
----- Original Message -----
From: <ss_nospam@no___spam_spam.com>

Newsgroups: borland.public.cppbuilder.graphics
Sent: Friday, February 02, 2001 7:33 PM
Subject: Dos window closes too fast..

Other Threads