当我在 c++ 中使用 system( "command" ) 时,我可以调用 cygwin 而不是普通命令行吗?
When I use system("command") in c++, could I call the cygwin instead of normal command line?
通常,我在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
替换为适当的位置。
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 函数调用中参数的顺序重要吗
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 在c++类上调用void函数
- 为什么 std::unique 不调用 std::sort?
- 调用专用模板时出错"no matching function for call to [...]"
- 选择要调用的构造函数
- C++为什么尽管我调用了void函数,它却不起作用
- 构造函数正在调用一个使用当前类类型的函数
- 变量没有改变?通过向量的函数调用
- 没有为自己的结构调用列表推回方法
- 调用'begin(int [n])'没有匹配函数
- 调用C#中的Cygwin GCC DLL挂在malloc上
- 如何从.NET Core调用cygwin编译的C++
- 加载cygwin C++dll,调用类函数
- 当我在 c++ 中使用 system( "command" ) 时,我可以调用 cygwin 而不是普通命令行吗?