system(“pause”); – Why is it wrong?

t’s frowned upon because it’s a platform-specific hack that has nothing to do with actually learning programming, but instead to get around a feature of the IDE/OS – the console window launched from Visual Studio closes when the program has finished execution, and so the new user doesn’t get to see the output of his new program.

Bodging in System(“pause”) runs the Windows command-line “pause” program and waits for that to terminate before it continues execution of the program – the console window stays open so you can read the output.

A better idea would be to put a breakpoint at the end and debug it, but that again has problems.

Leave a Comment