C + + compiled in a separate console program execution time, often a flash, can’t see the output results, in order to solve this problem, there are a lot of people use the system (” pause “) to suspend, but so are a lot of disadvantages, there are two reasons for
a: poor portability
2: consume resources is very big, in both Windows and Linux
Instead of using system(“pause”) to pause, you can use STD ::cin.get() or getchar()
. Why not system(“pause”)?
Let’s take a look at the flow of system(“pause”)
1: Pause your program
: Start the Shell in the sub-process
3>ind commands to execute and allocate memory for them
4: Wai>r input
5: Recluse m>y
6: End the Shell <>> 7: Continue your program>
To summarize, use STD ::cin.get() or getchar() to pause the execution of a C ++ program
PS: the original http://www.gidnetwork.com/b-61.html
Reproduced in: https://blog.51cto.com/zhanggx/1305045
Read More:
- C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference
- 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)
- Solution to the flash of running result of dev C / C + +
- Two lines of code to solve your vs flashback problem
- Solution of vs program flashback problem
- Flash back after vs compiler running, processing method
- Causes and solutions of black frame flashback after debugging visual studio 2017
- C language — to solve the problem of program flashback when programming (in VS)
- Solution of command line window flashback when visual studio runs C + + program
- The solution of console flash in C + +
- The problem of flash back by pressing enter window when debugging or executing program in Visual Studio C
- The method of getting shell command output in Python
- The solution of flashing back after the end of console program running
- HYDU_ create_ Process (. /utils/launch/launch.c:69): execvp error on file.. Error handling
- [vs console program flashback]
- Python3 reports an error [errno 5] input / output error. Print is used when there is no stdout
- Several calculation methods of Python execution time
- Usage of pause function in MATLAB
- Three solutions to flash back of program running result box under vs