The program terminates just when it starts (Novice Question)

Hi

I'm new to C++, and I was following the tutorials on this website. I'm using visual studio 2008 and when I run the program it terminates just when it starts. Here is the code:

1
2
3
4
5
6
7
8
9
10
// my first program in C++

#include <iostream>
using namespace std;

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


This is the process I follow:

I make a .cpp file containing the code above, and then in VS I choose File\New\Project From Existing Code

Then I choose C++ as the project type, I browse the folder containing the .cpp file as the project file location. Then I choose console application project. Afte that I run the program, and a cmd window appears containing the Hello World! text and then the program ends instansly.

I wonder, is the code supposed to act in this way? Or do I do something wrong in Visual Studio?

Thanks for your time :)

Kindest Regards
GBStudio
Last edited on
Right before you have 'return 0;' put:
system("PAUSE");
Thanks a lot :)

Kindest Regards
GBStudio
Topic archived. No new replies allowed.