(By Tan Tan)
First, problem description
The original code looks like this:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
return 0;
}
The function is to print Hello World! From a command line window. However, the command line window will flash back as soon as I run it, and I haven’t even had time to read my Hello World!!
Second, solutions
Tried several methods of website, the following several works:
remember the following words are added before the return!!!!!!!!!
1. Add this sentence before return 0:
getchar();
2. Add this sentence before return 0:
system("pause");
3. Add this sentence before return 0:
cin>>name
The principle of these methods is the same, all want the command line window to wait for you to enter a signal before proceeding to execute, you do not enter a signal better stop there. Getchar () and cin> > The name is all about identifying what you’re typing, and the system(” pause “) should be free to enter a single character without identifying what you’re typing. Another way to do this is to write cin.get () before it; Get what you type, not type it and then execute it.
Read More:
- The reasons and common solutions of vs flash back on the road of C + + Learning (with reasons attached)
- The problem of flash back by pressing enter window when debugging or executing program in Visual Studio C
- Causes and solutions of black frame flashback after debugging visual studio 2017
- C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference
- C + + uses system (“pause”) to pause black windows
- use cin.get () instead of system (“pause”) to avoid the flash of C + + programs
- Solution to the flash of running result of dev C / C + +
- Flashback problem of output window of visual studio 2017 console program
- C++ foundation — clear/erase/pop of string class_back
- C language — to solve the problem of program flashback when programming (in VS)
- Two lines of code to solve your vs flashback problem
- Three solutions to command line flashback in VS
- [vs console program flashback]
- There are three ways to deal with the problem of vs (Visual Studio) 2017 flashback. I feel that none of them is the fundamental solution.
- Some solutions to the problem of windows flashback after vs running
- Solution to the flash of visual studio console program output window
- Solution of vs program flashback problem
- Flash back after vs compiler running, processing method
- Visual studio console program output window flashed by
- Solution for flash back of vs2015 running interface