Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c++; < P>我想在一个系统()函数C++中执行2个CMD命令,但是一个CMD命令作为级联传递: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { System::String^ managedString = textBox1->Text; msclr::interop::marshal_context context; std::string standardString = context.marshal_as<std::string>(managedString); std::string s2 = "yara64 -r test.yara " + standardString; system(s2.c_str() && "pause"); } private:System::Void按钮1\u单击(系统::对象^sender,系统::事件参数^e){ 系统::字符串^managedString=textBox1->Text; msclr::interop::封送上下文; std::string standardString=context.marshal_as(managedString); std::string s2=“yara64-r test.yara”+标准字符串; 系统(s2.c_str()&“暂停”); }_C++_Windows_Winforms_Cmd_C++ Cli - Fatal编程技术网 Text; msclr::interop::封送上下文; std::string standardString=context.marshal_as(managedString); std::string s2=“yara64-r test.yara”+标准字符串; 系统(s2.c_str()&“暂停”); },c++,windows,winforms,cmd,c++-cli,C++,Windows,Winforms,Cmd,C++ Cli" /> Text; msclr::interop::封送上下文; std::string standardString=context.marshal_as(managedString); std::string s2=“yara64-r test.yara”+标准字符串; 系统(s2.c_str()&“暂停”); },c++,windows,winforms,cmd,c++-cli,C++,Windows,Winforms,Cmd,C++ Cli" />

如何在c++; < P>我想在一个系统()函数C++中执行2个CMD命令,但是一个CMD命令作为级联传递: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { System::String^ managedString = textBox1->Text; msclr::interop::marshal_context context; std::string standardString = context.marshal_as<std::string>(managedString); std::string s2 = "yara64 -r test.yara " + standardString; system(s2.c_str() && "pause"); } private:System::Void按钮1\u单击(系统::对象^sender,系统::事件参数^e){ 系统::字符串^managedString=textBox1->Text; msclr::interop::封送上下文; std::string standardString=context.marshal_as(managedString); std::string s2=“yara64-r test.yara”+标准字符串; 系统(s2.c_str()&“暂停”); }

如何在c++; < P>我想在一个系统()函数C++中执行2个CMD命令,但是一个CMD命令作为级联传递: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { System::String^ managedString = textBox1->Text; msclr::interop::marshal_context context; std::string standardString = context.marshal_as<std::string>(managedString); std::string s2 = "yara64 -r test.yara " + standardString; system(s2.c_str() && "pause"); } private:System::Void按钮1\u单击(系统::对象^sender,系统::事件参数^e){ 系统::字符串^managedString=textBox1->Text; msclr::interop::封送上下文; std::string standardString=context.marshal_as(managedString); std::string s2=“yara64-r test.yara”+标准字符串; 系统(s2.c_str()&“暂停”); },c++,windows,winforms,cmd,c++-cli,C++,Windows,Winforms,Cmd,C++ Cli,这个代码不起作用。仅当我删除“暂停”命令时,此操作才有效。如何在一个系统()中准确执行“暂停”命令 请帮帮我。非常感谢 使“&&”成为字符串本身的一部分 std::string s2 = "yara64 -r test.yara " + standardString + "&& pause"; system(s2.c_str()); “&&pause”应该是字符串的一部分,因此它应该如下所示: std::string s2 = "yara

这个代码不起作用。仅当我删除“暂停”命令时,此操作才有效。如何在一个系统()中准确执行“暂停”命令

请帮帮我。非常感谢

使“&&”成为字符串本身的一部分

std::string s2 = "yara64 -r test.yara " + standardString + "&& pause";
system(s2.c_str());
“&&pause”应该是字符串的一部分,因此它应该如下所示:

std::string s2 = "yara64 -r test.yara " + standardString + "&& pause";

system(s2.c_str());

您确实不应该使用
系统
。请先在std::字符串中输入&&和暂停。与其尝试组合字符数组。
&&
不连接字符串,而是逻辑and运算符返回布尔值。您能否将
&&
括在引号中,以便执行环境将其解释为单个命令,而不是将其解释为逻辑and<代码>标准::字符串s2=“yara64-r test.yara”+标准字符串+”和暂停“?”??啊,有人比我抢先一步。−1这不是真正的代码。那是不可能编译的。投票结束,因为缺少可复制的示例。−1“不惜一切代价学习避免system()”会给你带来一种归属于一些没有思想的群体的舒适感带来沉重的代价。“这是胡说八道。@干杯!总有更好的方法来完成
system()
可以使用的每一种情况。您上次在自己的代码中使用
system()
是在什么时候?Re“总有比
system
更好的方法。”,不,实现这一点的特定于系统的DIY代码并不更好。这需要开发和测试成本,而且可移植性有限。一般来说,重新创建标准库不是一个好主意,不惜一切代价避免它的建议是愚蠢的。“特定于系统的DIY代码”-这正是使用
system()
所需要的。“…标准库…以及不惜一切代价避免它的建议是愚蠢的”记住
gets()
?我确实喜欢balderdash这个词。“system()调用的shell是实现定义的[即特定于系统的]“,而你建议的替代方案更是如此。这对我来说是一种奇怪的无效逻辑。我确实明白,许多如此之多的读者至少假装同意这些东西,只是为了属于一群志同道合的人,而且我的从众本能显然异常微弱,但仍然是:基本逻辑什么时候过时了?