2014-12-18 36 views
2

我已經在Netbeans上爲C和C++編程安裝了MinGW。
這裏是我試圖NetBeans上運行一個簡單的代碼:無法從netbeans輸入值,但在cmd中工作

#include <stdio.h> 
int main(int argc, char** argv) { 
    printf("Inside Main...\n"); 
    int n; 
    printf("Enter : "); 
    scanf("%d", &n); // When I remove this line, it is working. 
    printf("You have entered %d.", n); 
    return (1); 
} 

每當我嘗試訪問從NetBeans中控制檯的任何價值,我看不到任何東西。

輸出用的scanf(...)

enter image description here

輸出沒有的scanf(...)

enter image description here

如果我嘗試運行這些代碼從CMD,所有工作

+1

我不知道嘗試添加'printf的後'\ N' 「輸入.. \ n」);' – Gopi

+1

我不知道太多,但你可以嘗試'fflush(標準輸出)); '。 – OiciTrap

+0

[可能出現[使用scanf在NetBeans中無法正常運行]的重複](http://stackoverflow.com/questions/9116958/programs-with-the-scanf-not-working-properly-in-netbeans) – Rizier123

回答

2

對於scanf()您必須使用Netbeans External Terminal

enter image description here

正常運行

enter image description here

您還可以使用Netbeans Standard Output
但這更具誤導性。
當你看到一個空終端做輸入123

enter image description here

命中進入後,你得到的輸出的一次。

enter image description here