Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想通过我的 C 应用程序运行一个 cmd 程序,并能够获取输入并将输出发送到 cmd。我能做这样的事吗?
谢谢。
您正在寻找的功能是system(cmd). 您可以正常运行命令(输出将直接打印到屏幕上):
system(cmd)
system("command.exe");
或者在文件中捕获输出 ( stdout):
stdout
system("command.exe > file.txt");