Many beginners of C + + will start from the console, but the code is often flashed over, (some compilers will not have such a situation).
For example:
#include <iostream>using namespace Std;//main function is a program's entry//int is an integer type (integer)//main The return value of the function is an integer type, So to declare the return type (int) int main () { cout<< "Hello world!" before the function name <<endl; Cout is provided by the standard library, so introduce namespaces: using namespace std; And Endl is a newline, ie (End line) //code from <a target=_blank href= "http://blog.csdn.net/imcjysy/article/details/43838459" >http://blog.csdn.net/imcjysy/article/details/43838459</a>, a C + + Hello World Program}
The program compiles a black window that flashes past, and we call it a console.
Many beginners are stuck here, this is not a problem with the code, is not a compiler bug,
Workaround:
Add a cin.get () in the main function;
The function of Cin.get is to read the carriage return at the end of the line.
Now the program will not flash past.
Attention:
Some places with a cin.get (), not enough, need to use two. (only a few cases)
C + + console flashed through