VS2013 调试窗口一闪而过的解决方法

使用开发集成环境vs2013时,常会遇到调试窗口一闪而过,通过查阅资料,现已解决。

简单写了一个加法器,测试代码如下

 1 #include <stdio.h>
 2 
 3 int main()
 4 {
 5     /* 局部变量声明 */
 6     int a, b;
 7     int c;
 8     /* 实际初始化 */
 9     a = 10;
10     b = 20;
11     c = a + b;
12     printf("value of a = %d, b = %d and c = %d
", a, b, c);
13     return 0;
14 }

一般进行的操作是编译(F5),可先运行(Ctrl+F5),若还未解决,执行下列方法:

方法1  

  若是c 文件,程序添加头文件#include <stdlib.h>  且在程序最后句(return之前)添加system("pause");

  若是c++ 文件,在程序最后句(return之前)添加system("pause");

  效果如下

 1 #include <stdio.h>
 2 #include <stdlib.h>     //方法2
 3 
 4 int main()
 5 {
 6     /* 局部变量声明 */
 7     int a, b;
 8     int c;
 9     /* 实际初始化 */
10     a = 10;
11     b = 20;
12     c = a + b;
13     printf("value of a = %d, b = %d and c = %d
", a, b, c);
14     system("pause");    //方法2
15     return 0;
16 }

方法2

  右键单击当前工程,进入属性界面,

  链接器-系统-子系统,子系统配置“控制台 (/SUBSYSTEM:CONSOLE)”,

  然后执行运行即Ctrl+F5。

运行结果如下

这样便可解决一闪而过!

原文地址:https://www.cnblogs.com/gaigaichen/p/6909134.html