Section 5 - Alternate Form

1A.5.1 (Optional) Alternative Form of Hello World! If  Needed

If you don't set up your project just right (i.e., if you miss some detail in my instructions which follow), you might find that the output window disappears before anyone has a chance to appreciate the run.  If you only see a **flash** instead of a nice output window,  you can try a second form of the program:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
cout << "Hello World!\n";

// add this line to avoid flash:
{ cout << flush; getchar(); }

return 0;
}

The additional line that is placed in the middle of this program is a trick to force the screen to pause until you, the user, hit a key on the keyboard. This will give you time to do a copy/paste, thus capturing a copy of the program run before you hit a key to terminate the program.

In the next module, when you actually try to run your program, try the original version first.  If that creates the aforementioned flash,  and the console window does not stay the screen, you can then replace it with this workaround version.