如何通过C程序打开Cmd(命令提示符)
实际上,我想通过C程序执行DOS命令,并想在我的C输出窗口中显示DOS命令的输出。
示例:
使用“dir C:\”显示 C 程序的输出
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要在运行 C 程序的同一
cmd.exe
窗口中执行命令:要启动单独的窗口,您需要调用
cmd.exe
:(注意:我还没有测试过这个) ;
To execute a command in the same
cmd.exe
window where your C program is running:To launch a separate windows, you need to call
cmd.exe
:(Note: I have not tested this one);
应该转储到当前的标准输出中
should dump in the current stdout
但 system() 是邪恶的。原因如下: http://www.cplusplus.com/forum/articles/11153/ 确保在使用它之前经过深思熟虑。
But system() is evil. Here's why: http://www.cplusplus.com/forum/articles/11153/ Make sure you give thorough thought before using it.