It's pretty simple what I'm trying to do, and I'm merely having trouble figuring out the right syntax.
I want my struct to look like this:
struct myStruct
{
functionPointer myPointer;
}
Then I have another function somewhere else that passes a function to a function and returns an instance of my struct. Here's what it does:
struct myStruct myFunction(int (*foo) (void *))
{
myStruct c;
c.myPointer = foo;
return c;
}
How can I make this actually work? What's the correct syntax for:
- Declaring a function pointer in my struct (obviously
functionPointer myPointer;
is incorrect) - Assigning a function's address to that function pointer (pretty sure
c.myPointer = foo
is incorrect)?