passing struct member to function
I don't know what else to do. For hours I've been trying - but no luck.
Here is the problem:
Code:
typedef int (*fnptr)(double, double);
...
struct abc
{
char check1[3], check2[3], check3[3];
...
fnptr func1, func2, func3;
}mystruct;
...
int foo1(double t1, double t2) { ... }
...
void myfunc(const char a[], fnptr ptr)
{
if(strcmp(a, "foo")
ptr = func1; // gcc error: assignment from incompatible pointer types
....
}
...
int main()
{
...
myfunc(mystruct.check1, &mystruct.func1);
....
return 0;
}
What am I doing wrong? How can I pass the two struct members (check1, func1) to the function myfunc()? I must pass the function pointer 'func1' by reference.
Thank you for your help.