|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#9
|
||||
|
||||
|
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); } ... } } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Summer camp program eval. | Andrew Schuetze | General Forum | 3 | 12-06-2006 22:16 |