News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Prevent Console Application from closing to fast...

Started by Matthias, May 25, 2005, 01:40:18 PM

Previous topic - Next topic

Matthias

Hi there,

i'm very new to programming in C (new to programming anywhere).
How can i prevent the console from closing very fast after running a programm (for instance when i compile "hello world" and let it run i see the console popping up but it closes so fast i can't recognize anything...)

Thanks for you tipps and advices!

Matthias

P.S.: Sorry for my bad englisch!

aben

The simple solution is:


int main()
{
 std::string str;
 std::cout << "Hello world!" << std::endl;
 std::cin >> str;
 return 0;
}

squizzz


#include <iostream>

int main()
{
std::cout << "Hello world!" << std::endl;
system("pause");
return 0;
}


might work fine as well...
this space is for rent

rickg22

wait, didn't the console runner program do that automatically? :?

squizzz

Quote from: rickg22wait, didn't the console runner program do that automatically? :?
Hahaha yes it does. (checked)

But then, it doesn't seem to work for Matthias. :?
this space is for rent

mandrav

QuoteThe simple solution is:
aben, this is the way some other IDE does it. We provide the solution without you having to edit your code ;)

Matthias, if you 're still having problems, read this thread.

Yiannis.
Be patient!
This bug will be fixed soon...

aben

Ok, the new console_runner you supplied adds this feature.
-Now I ask, is there any way to close the console automatically when my application terminates - some settings in the environment for instance?

mandrav

Quote from: abenOk, the new console_runner you supplied adds this feature.
It seems that the supplied console_runner.exe with the finalbeta setup was screwed. Sorry guys.

Quote from: aben-Now I ask, is there any way to close the console automatically when my application terminates - some settings in the environment for instance?
LOL! I never expected this. It was always the other way around  :lol:
Anyway, submit a feature request and I 'll make it configurable.

Yiannis.
Be patient!
This bug will be fixed soon...

aben

Feature request submitted...
I believe that it would really begin to annoy me if I had to press enter after each run. -So for now I'll use the "screwed" version of the console_runner  :)