Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

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

Entry

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()
example...
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:
<?php
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.
--Nate
Email: [email protected]
=======
thescripts.com/forum/thread592791.html
i hope that helps.
http://americanahost.com
http://www.qwesz.com
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.mozmar.com
http://www.yamot.com
http://www.templatestemp.com