开发者

Problem with executing interactive C programs using PHP

I'm havin开发者_运维百科g problems with executing C programs using PHP. I have just used exec() function to execute C file in the system. The problem is that I cannot able to give the run-time inputs to the C-program. When I used the scanf() function in C, the system automatically takes some default values(garbage values) as an input and produces some output. How can I overcome that problem. Please give me the code to make the C-program execution interactive in PHP.


you must use popen("yourprogram","w") to run external executable and give input to the program from your script. http://php.net/manual/en/function.popen.php


If you need to pass some input to your C program and get back the results, you should use proc_open. The sample on manual page explains everything, so I'll neither invent another one nor just copy it here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜