Code:#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout << "Hello World\n\n";
cout << "Press a ENTER to continue...";
getch();
return 0;
}
Printable View
Code:#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout << "Hello World\n\n";
cout << "Press a ENTER to continue...";
getch();
return 0;
}
There are many different ways of pausing the program so that the console stays open. Use whatever works for you and makes you happy, but be aware that solutions like system("pause") and getch() won't work for some other people, so when you post your code for help, some people won't take the time to change your code so that it will compile and work on their machines.
If you use cin.get(), it will compile and run on everybody's machines, but there are situations where it doesn't work by itself and requires an extra cin.ignore() before it.