How to take user input from HTML form to C program

maxzoel

I have this small program which takes input from stdin sample.c

#include<stdio.h>
main()
{
int l=0;    
scanf("%d",&l);
printf("\n%d",l);
}

ofcourse! compiled it: cc sample.c and got a.out and i am trying to run it via php like

$runcmd = "./a.out > output.txt";
exec($runcmd,$outp); 
print_r($outp);

my problem is i dont have any idea how to give input to this program so that scanf can read that? please help me here!

googling gave some tips like proc_open, popen .... but i couldn't make it.

Thanks in Advance.

Puggan Se

take a look at popen http://se1.php.net/popen

it works a bit like fopen, and when using fwrite, insted of writing to a file you can write to a prosses stdin insted.

$runcmd = "./a.out > output.txt";
$process_stdin = popen($runcmd, 'w');
fwrite($process_stdin, "text to send to process");
pclose($process_stdin);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How take *args input from user in a function

How to take input from user and change directory

How to take a variable from inside a html form that wasn't inputted by the user and output it to flask app?

How to take a user input (from scanner) and convert the entire input into ascii

C -- How to take care of sensitive input in C program?

How to Display User Input of a HTML Form

How to take input in beginning of the program?

How to make a Java program take input from an iOS app

How to take input from user ( which is a list ) and store values in array in c++?

How do I take font input from the user in c# WinForms

Java simple program not allowing to take user input

Program to take in user input & display it Problems

Take input as a row from user

How to get user input from javascript form?

How can I take live input from a form, and print it?

How to take input in this form in python?

Hello, is it possible to take user input of height and width from a form input and resize a picture in cm as output?

How can I take input from user and store it in a vector?

How to take user input from main method to another class and method?

How to take user input from a single line in NumPy array?

How do i take input from user and search api?

How to take input from user in the middle of print statement

How to take input from the user in Javascript, while loading the code.

Linux How to take hostfile as an input from user and call it into script

How can I take a input from user and change it with setState?

How to take folder location as an input from user in jsp?

how to use models to take an input as a file from user in django?

How to take input from user and save that into other file

how to use BufferedReader class to take character and string input from user?