Actually, I want to execute DOS command by a C program and want to display the output of DOS command in my C Output Window.
example:
use "dir C:\\" which displays output to C- program
To execute a command in the same cmd.exe
window where your C program is running:
#include <stdlib.h>
.
.
.
system("dir C:\\");
To launch a separate windows, you need to call cmd.exe
:
system("cmd.exe /c dir c:\\");
(Note: I have not tested this one);
But system() is evil. Here's why: http://www.cplusplus.com/forum/articles/11153/ Make sure you give thorough thought before using it.
system("dir");
应该在当前的标准输出中转储
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.