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.

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:
- C + + uses system (“pause”) to pause black windows
- The reasons and common solutions of vs flash back on the road of C + + Learning (with reasons attached)
- C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference
- The solution of console flash in C + +
- Three solutions to flash back of program running result box under vs
- use cin.get () instead of system (“pause”) to avoid the flash of C + + programs
- C language — to solve the problem of program flashback when programming (in VS)
- Solution of vs program flashback problem
- Solution of command line window flashback when visual studio runs C + + program
- Some solutions to the problem of windows flashback after vs running
- Flash back after vs compiler running, processing method
- Two lines of code to solve your vs flashback problem
- Solution to the flash of running result of dev C / C + +
- [vs console program flashback]
- The solution of flashing back after the end of console program running
- Flashback problem of output window of visual studio 2017 console program
- In vs programming, the code of Ctrl + F5 is flashback
- Visual studio 2012, a complete collection of solutions to flash back windows after running
- Solution to the flash of visual studio console program output window
- Solution to the flash of visual studio 2017 running program