The solution of console flash in C + +

When you write a C ++ program in VS, you will find that when you run the program, the console will flash by and you will not see the results of the program. Therefore, you need to find a way to make the screen or console pause.
 

    method one: increase the input statement at the end of program, this will require the user to input before the end of the program runs, the console will stay there, specific code as shown in the figure below
    alternative Rich two alternatives: in C: printf (” press any key to continue…” );
    getchar(); 12 In C++ : Cout<; <" Press any key to continue..." ;
    cin.clear();
    cin.sync();
    cin.get(); 1234 plus cin. The clear (), cin. The sync () these two words, is to empty the cache area, let cin. The get () to receive your real keyboard input method
    2: add the statement at the end of the program: system (” pause “); Things to Avoid in C/C++ — system(“pause”) is not recommended because:
    is not portable: only for DOS or Windows, not Linux, etc.
    consumes system resources: Calling the system command system() to “suspend the program” is overkill.
    must add a header file: stdlib.h or cstdlib. There are many header files in C ++ that already contain this file, so it is sometimes possible to use this function without the header stdlib.h, but it is better to add it for safety reasons. Method 3: To modify the project configuration, right-click on the project, select Properties from the right-click menu, and then select “Configuration Properties” from the list on the left of the pop-up dialog box –>; ‘Linker’ –>; “System”, then in the list on the right, in the first “subsystem” value, select “Console” (/SUBSUSTEM:CONSOLE) “as shown in the figure below

    Read More: