The reasons and common solutions of vs flash back on the road of C + + Learning (with reasons attached)

First of all, it’s normal to flash and go away.

Because the program statement is executed sentence by sentence, nothing makes it pause, at the speed of computer execution, of course, flash by.

What we need to do is make the system wait and pause so that it doesn’t flash back (some compilers automatically add this feature at the end of the code to prevent novice users from seeing the output).

1) add system(“pause”) before return;
Note: system() is the call to the system command; Pause command; “Press any key to continue..”

Note: getchar reads the next character, so it “pauses” while waiting for us to type.
It’s worth noting that sometimes you might need to add two getchar(), because the first getchar() might eat the carriage return or something like that.

3) Press Ctrl +F5 to run
Note: Ctrl +F5 is a program that debugs without debugging. It automatically “pauses” at the end of the program, so the DOS command prompt “Press any key to continue….” is added.
The little triangle we clicked on, which starts debugging (F5), does not automatically add “pause”, so it will flash past.

The above is only the idea after I consult the data to think, welcome everyone fellow middlemen to give correct, next will be very grateful!

Read More: