Just replace getch()
with cin.get()
like this:
include <iostream>
using namespace std;
void main()
{
cout << "Hello World!" << endl;
cin.get();
}
For more details see get() function documentation. Just for reference you may do this, for example, to wait until user pressed a specific character:
void main()
{
cout << "Hello World!" << endl;
cout << "Press Q to quit." << endl;
cin.ignore(numeric_limits<streamsize>::max(), 'Q');
}