Two solutions for VC++ crash (1 and then select "Start execution (not debugging)", that is ctrl+F5; 2system("pause");)

In the past few days, I changed the development integration environment to vs2010. I just started to use it, but I didn’t understand it very well in some places. I can solve it by consulting related documents.

Take the VS2010 debugging window flashed by the solution as follows:

[cpp]  view plain  copy

  1. #include <iostream>  
  2. using namespace std;  
  3. void main()  
  4.  {     int add(int,int,int);  
  5.        float average(int);  
  6.        int x,y,z, sum;       
  7.        cout<< "Input x, y, z:";  
  8.        cin>>x>>y>>z;  
  9.        sum=add(x, y, z);  
  10.        cout<<"sum="<<sum<<endl;  
  11.        cout<<"average="<<average(sum)<<endl;   
  12.    // system("pause");//Prevent the system window from flickering and disappear, method one  
  13.  }  
  14.   
  15. int add (int a, int b, int c)  
  16. {     
  17.   return (a+b+c);     
  18.   }  
  19. float average (int s)  
  20. {     
  21.    return  (s/3.0);   
  22.  }  


 

The above is the test code.

The solution is as follows:

If the operation performed at this time is to compile (F5), you can run the program (Ctrl+F5) first, if it still flashes, use the following method to solve it.
Method 1:
1. If it is a C++ file, write a sentence at the end of the program (before return) and add: system("pause");
2. If it is a C file, first add a header file in the program header: #include"stdlib.h"; then Write a sentence at the end of the program (before return) and add: system("pause").
Method 2:
1. Right-click the current project-Properties 
2. Select Configuration Properties-Linker-System 
3. Change the "Subsystem" configuration in the system options, and select the first "Console (/SUBSYSTEM:CONSOLE) in the drop-down menu )"
and then select "Start execution (not debugging)", which is ctrl+F5;

This will solve the problem of window flashing once and for all.

Guess you like

Origin blog.csdn.net/qq_25814297/article/details/108846639