If this is just for reading the output, you do not need the program to remain βliveβ, just run it from the command window and the output will remain visible. You can also use the debugger to interrupt execution at a specific point.
There are many ways, good and bad, to do this with code:
#include <iostream> using namespace std; int main() { cout << "Hello World! "; cin.get(); // Wait for some input, as suggested by PigBen return 0; }
or
#include <iostream> using namespace std; int main() { cout << "Hello World! "; Sleep(1000); // one second return 0; }
or, although this is a bad idea:
#include <iostream> using namespace std; int main() { cout << "Hello World! "; while (true) { } return 0; }
What are you trying to achieve?
Edited to notice that endless loops are bad, although they technically support the program forever.
ssube source share