PHP 系统() 参数
我有以下执行C++程序并输出它的代码:
<html>
<head>
<title>C++</title>
</head>
<body>
<div><?php
system("app.exe", $out);
echo rtrim($out, "0");
?></div>
</body>
</html>
我怎样才能做到你可以将参数传递给c++程序 ,像这样说...
如果这是c++程序
#include <iostream>
#include <string>
int main(){
string input = getarg();//Not really a function, just one I kinda want to know
cout << input;
return 0;
}
我可以做这样的事情吗?
<html>
<head>
<title>C++</title>
</head>
<body>
<div><?php
system("app.exe arg=hello-world", $out);
echo rtrim($out, "0");
?></div>
</body>
</html>
我不知道很多部分对于这个问题,我可以执行程序,但我只是需要传递参数。
I have the following code that executes a C++ program and outputs it:
<html>
<head>
<title>C++</title>
</head>
<body>
<div><?php
system("app.exe", $out);
echo rtrim($out, "0");
?></div>
</body>
</html>
How can I make it so that you can pass arguments to the c++ program, say like this...
If this was the c++ program
#include <iostream>
#include <string>
int main(){
string input = getarg();//Not really a function, just one I kinda want to know
cout << input;
return 0;
}
Could I do something like this?
<html>
<head>
<title>C++</title>
</head>
<body>
<div><?php
system("app.exe arg=hello-world", $out);
echo rtrim($out, "0");
?></div>
</body>
</html>
I don't know a lot of parts to this problem, I can execute the program but I just need to pass arguments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在命令后传递以空格分隔的参数,例如
system("app.exe hello-world 2 3", $out);
在你的 C++ 程序中
You can pass the arguments space separated after the command like
system("app.exe hello-world 2 3", $out);
in your c++ program