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
- CIN in C + + cin.get ()、 cin.getline (), getline(), gets() function
- C++ cin.ignore Use of ()
- How to use C # to get image format without system. Drawing. Common
- Solution to the flash of running result of dev C / C + +
- The solution of console flash in C + +
- Web Crawler: How to get the data in the web page and disguise the header, disguise as a browser to visit many times, avoid a single visit leading to IP blocked
- In C + + cin.getline The difference between () and getline () functions
- C language program running results flash back how to do
- The reasons and common solutions of vs flash back on the road of C + + Learning (with reasons attached)
- The problem of window flash after C + + program is compiled and run
- How to Use Apt get Command Under Mac OSX
- FTP use get command 550 failed to open file, but use the put command to solve the problem
- Usage of pause function in MATLAB
- Solution to msxml3.dll error ‘800c0008’ the system cannot locate the resource specified
- The problem of flash back by pressing enter window when debugging or executing program in Visual Studio C
- The problem of C + + compile result window flash by
- The solution of “failed to load ldlinux. C32” in Linux system
- STOP: c000021a { Fatal System Error } the initial session process or system process terminated …