当我在 c++ 中使用 system( "command" ) 时,我可以调用 cygwin 而不是普通命令行吗?

When I use system("command") in c++, could I call the cygwin instead of normal command line?

本文关键字:cygwin 调用 我可以 命令行 c++ command system      更新时间:2023-10-16

通常,我在c++应用程序中使用system("command line"),我将在命令提示符中执行该命令。有没有其他的代码,我可以直接在Cygwin中执行我的命令?

system()函数在Windows中使用cmd。但是,可以从命令行实例化Cygwin并运行命令,如下所示:

system("C:/cygwin/bin/bash -c "echo hi"");

这将导致Cygwin bash运行命令echo hi,并将输出打印到程序的标准输出中。

如果您在其他地方安装了Cygwin,请确保将C:/cygwin/bin/bash替换为适当的位置。