Console app closes after execution



 DEVELOP > c-Plus-Plus > Console app closes after execution

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "James"
Date: 12 Oct 2005 04:59:04 PM
Object: Console app closes after execution
I'm totally new to C++ and when I try to execute the simple program I have
written, it closes the console application as soon as it has finished
excuting. This obviously means I cannot see the contents of the console
window.
I'm developing it using Visual C++ 2003, using the console application
template.
.

User: "jalkadir"

Title: Re: Console app closes after execution 12 Oct 2005 08:03:04 PM
911!
NO!
This is is the way you do it, please take my advice...
int main(){
std::cout << "I want to see this message" << std::endl;
std::cin.get(); // pause until I press enter...
return 0;
}
The std::cin.get() is what you want to use.
This the true C++ way to handle your problem.
Have fun James!!
.
User: "=?iso-8859-1?Q?Ali_=C7ehreli?="

Title: Re: Console app closes after execution 12 Oct 2005 08:15:26 PM
"jalkadir" <jalkadir@gosonic.ca> wrote in message
news:1129165384.802470.147660@g44g2000cwa.googlegroups.com...

This is is the way you do it, please take my advice...
int main(){
std::cout << "I want to see this message" << std::endl;
std::cin.get(); // pause until I press enter...

If every program waited for a character from its standard input before
exiting, not much could be achieved in today's systems.

return 0;
}

The std::cin.get() is what you want to use.
This the true C++ way to handle your problem.

Taking a character from the standard input has nothing to do with the OP's
_program_; that is not a requirement of the program. The program does its
job and exits. No problem there...
The OP's problem is about not being able to see the output of the program.
That problem can be solved in a number of ways, one of which is to start it
in an environment with some history buffer.
Ali
.


User: "Maett"

Title: Re: Console app closes after execution 13 Oct 2005 12:56:47 PM
James wrote:

I'm totally new to C++ and when I try to execute the simple program I have
written, it closes the console application as soon as it has finished
excuting. This obviously means I cannot see the contents of the console
window.

I'm developing it using Visual C++ 2003, using the console application
template.

If you start the program out of the IDE, press "Ctrl-F5" instead of "F5"
to start. Then the console remains open with the message
"Press any key to continue"
at the end.
Maett
.

User: "Chris Gordon-Smith"

Title: Re: Console app closes after execution 12 Oct 2005 05:09:59 PM
James wrote:

I'm totally new to C++ and when I try to execute the simple program I have
written, it closes the console application as soon as it has finished
excuting. This obviously means I cannot see the contents of the console
window.

I'm developing it using Visual C++ 2003, using the console application
template.

Have you tried starting the application from a console that you have already
opened?
--
Chris Gordon-Smith
London
http://www.simsoup.info
.
User: "James"

Title: Re: Console app closes after execution 12 Oct 2005 05:13:55 PM
"Chris Gordon-Smith" <use.address@my.homepage> wrote in message
news:3r5fqtFi0eo0U1@individual.net...

James wrote:

I'm totally new to C++ and when I try to execute the simple program I
have
written, it closes the console application as soon as it has finished
excuting. This obviously means I cannot see the contents of the console
window.

I'm developing it using Visual C++ 2003, using the console application
template.


Have you tried starting the application from a console that you have
already
opened?

So simple. Can't believe I didn't think of it myself.
Thank you.
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER