my program won't stay open

okay so i just got my new c++ compiler
and i opened this website to learn how to do some programming
started off with the simplest thing.

#include <iostream>
using namespace std;

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

but every time i try to execute it it opens for like half a second and then closes again so i can't see it.
and i'm not touching anything

can someone please tell me what's wrong?
closed account (3qX21hU5)
Check out the sticky post... http://www.cplusplus.com/forum/beginner/1988/
Last edited on
thank you very much. working fine now :)
Which compiler are you using?
im using Dev-c++ 4.9.9.2
Dev c++ is now obsolete, see here:
http://www.cplusplus.com/forum/articles/36896/

Use Code::Blocks instead.
Not entirely obsolete. It was last updated on 31st December 2012, just three days ago. That's version 5.3.0.4.

http://orwelldevcpp.blogspot.co.uk/
http://www.cplusplus.com/articles/36vU7k9E/
Last edited on
I didn't know that, I was mistaken then.

Thanks for the link!
Though there is a problem. The search engines usually put the outdated version as the first link, and the new version somewhere lower down. So newcomers can easily be misled.
closed account (3qX21hU5)
Not that great with SEO technology but it probably is listed first because of all the traffic it used to get, and how many people still (surprisingly) use the outdated version.
I suspect Dev-C (and Turbo C) are still in use because they have so much academic momentum behind them. Schools (esp. in less prosperous countries) need to eek the most value out of the money they spent so they stick with what they know despite its looming obsolescence. Many teachers are also set in their ways or simply don't want to go through the time and trouble of bringing themselves up-to-speed in order to teach the newest versions.
I use this, it has always worked for me.

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";

system("pause");
return 0;
}
closed account (3qX21hU5)
Do not use system ("pause") it is a security problem among other things so it is best to get into the habbit of not using it. Please see the sticky for why.
execute the program from the terminal/cmd prompt
OK DON'T PRESS EXCUTING
PRESS ( CTR F5 )
UR WELCOME :)
closed account (3qX21hU5)
What will CTRL F5 do? I believe on visual studios it runs the program without debugging it, but hes not on visual studios. I could be wrong but I don't think that works with dev C++ or codeblocks.
Topic archived. No new replies allowed.