Thank you
Jacques Rioux
Does the word 'parser' mean anything to you? Ever heard of
'yacc'? If you have, then you know what you have to do; if you
haven't, well...
--
- Paul J. Lucas
AT&T Bell Laboratories
Naperville, IL
I don't know if you have experience programming enough. The input
for a program (using scanf or not) can be only strings or numbers. If you
want convert the input string to a function, you should build lots of
procedures and data structures to handle it.
For example: you can convert the "formula" string into a binary tree
and then build functions to evaluate it.
3 x + 2
root
(+)
/ \
(*) 2
/ \
3 x
struct tree
{ typenode node;
struct tree *left,*right;
};
int evaluate (struct tree t)
{
if (number(t.node))
return (number (t.node));
return (operation (t.node,evaluate(t->left),evaluate(t->right)));
}
number :: function that return the value of numerical node.
operation :: function that make the operation t.node with our parameters.
GREETINGS FROM SPAIN
(SALUDOS)
==============================================================================
_/_/_/_/_/_/_/_/_/_/ | | Jose Antonio Espinosa
_/ _/ | | Laboratorio de Inteligencia Artificial
_/_/_/_/_/_/ | | Facultad de Informatica
_/ _/ _/ | | Universidad Politecnica de Madrid
_/_/ _/_/_/_/ | | espi...@alcala.dia.fi.upm.es
==============================================================================