The "syntax" for function pointer declaration is
Code:
returnType (*funcptr)(parameter(s));
e.g.
double (*compptr)(double, double);
The parenthesis is necessary to differentiate between pointer to a type and function pointers - it ties the pointer to the parenthesis after, rather than a function that returns a pointer to a "returnType".
What I'd like to understand is what you actually want to achieve with your string to function pointer conversion. But perhaps this is a way:
Code:
struct {
char *str;
int (*funcptr)(double, double);
} table[] = { { "compare", compare },
{ "add", add },
{ "sub", sub } };
Then just loop through table and compare the string with the "str" in the struct. Or if you need to do it "more clever", you build a hash-table or a sorted list so that you can search more quickly - assuming there is enough table entries and searches to require this.
--
Mats