The culprit, a missing line of code, system("pause"). With a system pause, your console will stop so you can actually view your code's output on the console screen. The system pause lets you pause the console until you decide to press enter. In fact it will print on the screen, Press Any Key to Continue. You can also use the cin statement to pause your console so you can see what your program calculated or printed.
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
//The console will close quicker than a bat's eye without a system pause
system("pause");
return 0;
}
No comments:
Post a Comment