By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,745 Members | 1,867 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,745 IT Pros & Developers. It's quick & easy.

how to pass commandline argument to C program from PHP code

P: n/a
hi frndz,

As we know that, we can pass command line agrument for C using
"scanf" commands, So as same as that, Is there any way to pass those
commandline arguments through php code to C and process them. If there
plz soon, or tel me any alternative for this

Rgrds
Dinesh..

Jan 29 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Did you mean execute C program like in command line ?

<?php
exec ("yourprogram -n 1234");
?>

--
http://www.mastervb.net
http://www.theukmap.com
On Jan 29, 11:28 am, balakrishnan.din...@gmail.com wrote:
hi frndz,

As we know that, we can pass command line agrument for C using
"scanf" commands, So as same as that, Is there any way to pass those
commandline arguments through php code to C and process them. If there
plz soon, or tel me any alternative for this

Rgrds
Dinesh..
Jan 29 '07 #2

P: n/a
ba*****************@gmail.com wrote:
hi frndz,

As we know that, we can pass command line agrument for C using
"scanf" commands, So as same as that, Is there any way to pass those
commandline arguments through php code to C and process them. If there
plz soon, or tel me any alternative for this
Hi Dinesh,

I'm not sure what you mean, because in C you don't use scanf to retrieve
commandline arguments. You use scanf to get user-input. You use the argc
and argv arguments in main() to access commandline arguments.
In PHP you have similar variables: $argc and $argv. $argc holds the
number of arguments and $argv is the array containing the values.

HTH.
Ruben.
Jan 29 '07 #3

P: n/a
On Jan 29, 2:21 am, Ruben van Engelenburg <nos...@nospam.comwrote:
balakrishnan.din...@gmail.com wrote:
hi frndz,
As we know that, we can pass command line agrument for C using
"scanf" commands, So as same as that, Is there any way to pass those
commandline arguments through php code to C and process them. If there
plz soon, or tel me any alternative for this

Hi Dinesh,

I'm not sure what you mean, because in C you don't use scanf to retrieve
commandline arguments. You use scanf to get user-input. You use the argc
and argv arguments in main() to access commandline arguments.
In PHP you have similar variables: $argc and $argv. $argc holds the
number of arguments and $argv is the array containing the values.

HTH.
Ruben.
What he passed you is a command forwarded to the command line of your
server. its exactly the same as if you were to go:

yourprogram -n 1234

Your program would have ARGC = 2 and ARGV would be {"-n", "1234"}

it has nothing to do with the scanf or anything like that.

Jan 31 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.