I need to access data from a C program, and without refreshing browser have that data displayed.
To start I tried a simple C program displaying text using printf("Hello"); and in the php section of the index.php file tried to run the C program and print its output. However, the real goal would be to maybe have a counter in the C program that counts up to 100, increment by 1 every second and in the browser without refreshing the page the value of that counter would be displayed as it changes.
testcode.c
#include<stdio.h>
int main()
{
pringf("Display message");
return 0;
}
index.php
<html>
<head>
<title>PHP Test</title>
</head>
<body><h1>html</h1>
<?php echo '<p>PHP</p>';
exec("gcc -o /home/birt/c-code.c",$output1,$returnvalue1);
exec("./c-code",$output2,$returnvalue2);
echo "<b> output :</b>"+$output2;
?>
</body>
</html>
When I point my browser to the server the HTML and PHP are displayed, however the output from the C program does not