|
Re: Eval() in C?
There is nothing like that (converting a string to a function address).
To simulate it, you would compare a variable (perhaps a string variable containing the name of your function) to some constant, then use a switch() statement to call the appropriate function. Example:
int foo( int a, int b)
{
return a + b;
}
int bar( int a, int b)
{
return a - b;
}
main()
{
char funcname[] = "foo";
...
switch (funcname)
{
case "foo":
foo(a,b);
case "bar":
bar(a,b);
}
...
}
}
|