2016-02-13 156 views
0

我試圖製作一個程序,它會在執行後關閉控制檯窗口。但它輸出這個:如何在程序之後關閉控制檯窗口?

(the program output) 
-------------------------------- 
Process exited after 15.7973 seconds with return value 0 
Press any key to continue . . . 

我不想看到這條消息,我只想讓程序將完全關閉窗口

我的程序結束:

... 
    if(getch==116){ 
    ... 
    } 
    system("pause >nul"); 
    return 0; 
} 

我使用的開發-C++。

+0

看起來像你使用的是IDE,您使用的是哪一個? –

+0

刪除'system(「pause> nul」);'直接運行程序,沒有IDE – Drop

回答

0

當您在IDE外雙擊運行exe或者在調試模式下使用F5運行時,控制檯窗口通常是關閉的。 避免使用系統(「暫停」)或系統(「暫停> NULL」)。 Avoiding "Press any key to continue" when running console application from Visual Studio

+0

「當您在IDE外雙擊運行exe時,控制檯窗口通常是關閉的 - >這就是原因。真??無論如何,謝謝! :-) 順便說一句。我正在使用DevC++,而不是Visual Studio –

0

刪除此行:

system("pause >nul"); 
+0

我試過了,也不行。 –

+0

@Waterflame:'pause'系統命令是保持窗口打開並等待輸入的命令。 – Pixelchemist

相關問題