(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:
- Flashback problem of output window of visual studio 2017 console program
- Solution to the flashback of visual studio output window
- The problem of flash back by pressing enter window when debugging or executing program in Visual Studio C
- Solution to the flash of visual studio console program output window
- The solution to the black window flash of running program on Visual Studio
- Visual studio console program output window flashed by
- Why does the result screen flash when visual studio runs the program?
- How to solve the problem that the console window disappears in a flash after visual studio 2017 runs
- 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.
- Causes and solutions of black frame flashback after debugging visual studio 2017
- Solution to the flash of visual studio 2017 running program
- The solution of windows not flashing back when visual studio console program is running
- Three solutions to command line flashback in VS
- Solution to flash back of visual studio 2017 running program
- C language — to solve the problem of program flashback when programming (in VS)
- Solve the problem of visual studio console flashback
- Visual studio 2017, OpenGL program running prompt glut32.dll missing solution
- Solution of vs program flashback problem
- [solution] visual studio will exit automatically after debugging the program
- Solution to the problem of console output window’s CMD flashing back when vs2015 writes C + + program