gpt4 book ai didi

php - 使用 php 运行 c 程序

转载 作者:可可西里 更新时间:2023-11-01 12:25:27 26 4
gpt4 key购买 nike

如何使用 php exec() 运行 c 程序我从谷歌搜索中看到了很多结果可以通过 exec() 函数但我无法使用它我这样试过我用c写了一个程序

**myc.c**
#include <stdio.h>

int main(int argc, char *argv[])
{
printf("Hello, world\n");

return 0;
}

**test.php**
<?php
exec('myc.c');
?>

谁能在这方面帮助我我通过放置在 www 文件夹中的 wamp 服务器执行了这个

最佳答案

C 程序

#include <stdio.h>

int main(int argc, char **argv)
{
if(argv[1])
printf("First arg %d\n", argv[1]);
if(argv[2])
printf("Second arg %d", argv[2]);
return 0;
}

PHP代码

<?php
exec("testone.exe 125 70", $out);
print_r($out);
?>

合并输出:

<!-- Array ( [0] => First arg 27 [1] => Second arg 27 ) -->

关于php - 使用 php 运行 c 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11808689/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com