我有以下代码执行C++程序 and 输出它:
<html>
<head>
<title>C++</title>
</head>
<body>
<div><?php
system("app.exe", $out);
echo rtrim($out, "0");
?></div>
</body>
</html>
我怎样才能做到这一点您可以将参数传递给 c++ 程序,这样说...
如果这是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;
}
我可以做这样的事情吗?
<html>
<head>
<title>C++</title>
</head>
<body>
<div><?php
system("app.exe arg=hello-world", $out);
echo rtrim($out, "0");
?></div>
</body>
</html>
I 不知道这个问题有很多部分,我可以执行程序但我只是需要传递参数。
您可以在命令后传递以空格分隔的参数,例如system("app.exe hello-world 2 3", $out);
在你的c++程序中
int main (int argc, char** argv) {
// argv[1] will be pointing to "hello-world"
// argv[2] => 2
// argv[3] => 3
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)