As you know, when you debug a C-language program, after you click Run, the running results often disappear after a flash. This is because the program we debug is not large, so it is basically too late to view the results, the window is automatically closed. You can add getch () before the main program returns, and press any key to close the window.
However, when debugging the C ++ program in the dev C ++ environment and learning to add getch (), an error is prompted. However, we can convert the original getch () to CIN. replace get () to get the same effect.
As follows:
# Include <cstdlib>
# Include <iostream>
Using namespace STD;
Int main (INT argc, char * argv [])
{
System ("pause ");
// Getch ();
Cin. Get ();
Return exit_success;
}
Actually, some function libraries using C ++ do not contain getch (). If we still use C function libraries, they can also be used in the dev C ++ environment, as follows:
# Include <stdlib. h>
# Include <conio. h>
Int main (INT argc, char * argv [])
{
System ("pause ");
Getch ();
// Cin. Get ();
Return exit_success;
}