Causes and solutions of black frame flashback after debugging visual studio 2017

After debugging, the black box flashes back, and the following error is displayed.

The reason:
Debugging mode at this time, the program will not be suspended, so the window will not continue to open state. So when the black box appears, it goes away.
Solution logic:
Causes the program to pause in a wait state.
Some compilers, such as Visual 6.0, perform this function automatically at the end of code execution.
Solutions:
Method 1: As shown in Figure 1, add a statement before the return statement: system (” pause “); System (” Pause “); Call the system pause command.
,
Method 2: getchar () before the return statement;

Either of the above methods can be used.
So it runs successfully.


Read More: