使用開發集成環境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\n", 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\n", a, b, c); 14 system("pause"); //方法2 15 return 0; 16 }
方法2
右鍵單擊當前工程,進入屬性界面,
鏈接器-系統-子系統,子系統配置“控制台 (/SUBSYSTEM:CONSOLE)”,
然后執行運行即Ctrl+F5。
運行結果如下
這樣便可解決一閃而過!