How to see the output of cout in Windows 7 (Complete newbie here)

Greetings!

This is my first time here but hopefully I will be making many many returns. I have found quite a bit of useful information for me down the road and this looks like a great community!

Let me start off by saying I am completely new to the world of programming but I've always wanted to learn a language. I am going through introduction chapters in MS Visual Studio 2010, and I just had a quick, most likely simple answer.

Whenever I compile a program, I am expecting to see an output using the "cout" command, but it seems that a command prompt window opens, then immediately closes so I am unable to see if the output was correct. Like I said, I'm completely new to this, but I am willing to learn and try things on my own. Any and all help is greatly appreciated. Thanks for your time! :)

- Gimp
Usually in Visual Studio the console remains open for you to see the output, well at least in the 2008 Edition. Nevertheless, simply add:

 
std::cin.get(); // the std:: does not need to be there if you are "using namespace std;" 


To the end of you program, just before return 0;

EDIT* the std::cin.get(); version used in Duoas' article is a more preferred method, however for my own applications this does suffice!
Last edited on
To add an extra thing,if you use .NET ,you can simply add Console::Read(); before return o;
Thanks guys! I used mcleano's solution (just adding cin.get() at the end) and it's great now! Thank you all for your very timely responses!
Topic archived. No new replies allowed.