2012-07-13 21 views
0

我想通過我的C應用程序運行cmd程序,並且能夠獲取輸入並將輸出發送到cmd。我可以做這樣的事嗎?來自C程序的cmd會話對話

感謝。

+0

在什麼操作系統?請將其添加爲標籤。 – Codo 2012-07-13 17:32:15

+1

請參閱[這個問題](http://stackoverflow.com/questions/450865/what-is-the-equivalent-to-posix-popen-in-the-win32-api)。 – 2012-07-13 17:33:42

回答

0

您正在尋找的功能是system(cmd)。您可以運行命令正常(輸出將直接顯示在屏幕上):

system("command.exe"); 

或捕獲在一個文件輸出(stdout):

system("command.exe > file.txt");