Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

22 of 27 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes


How do I call a c program from php, it has to pass a string with it and have ti return a string?

Mar 15th, 2008 17:55
ha mo, Articles Way, Nate Weibley,

I suspect you want to use exec()
C++ program:
#include <stdio.h>
void main(int argc, char *argv[]) {
	printf("Your command line arguemnts: ");
	for(int i=1;i<argc;i++) printf("%s",argv[i]);
php script:
exec("/path/program i am a cow",$lines);
foreach($lines as $theline) echo $theline."\n";
That would simply output:
Your command line arguments: i am a cow
I think.
Email: [email protected]
i hope that helps.