Avoid window flashing

Source: Internet
Author: User
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.