开发者

Problem with executing interactive C programs using PHP

开发者 https://www.devze.com 2023-03-30 01:46 出处:网络
I\'m havin开发者_运维百科g problems with executing C programs using PHP. I have just used exec() function to execute C file in the system.

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

精彩评论

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

关注公众号