how to pass variables from Asterisk to a C-script

Hi!I'm trying to write a script in C that Asterisk must call: I would to pass to the script a number digited by the user, make some elaboration with it and then pass the result to Asterisk. I don't understand the mechanism used by Asterisk to pass variable to/from a script: I know that variables are passed on the standard input and standard output but how can I make elaboration on them into the script? Can someone help me? thanks a lot!

up! any ideas?