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.
精彩评论