次の例を見てください。
// ptrFunc is the name of the pointer to the getFunction
void* (*ptrFunc)(void*, void*) = &getfunction;
// ... Declaring whatever lib and fname are
// Now call the actual function by using a pointer to it
ptrFunc(lib, fname);
// Another form of how to call getFunc might be :
(*ptrFunc)(lib, fname);
また、次のような別の関数に関数ポインタを渡すこともできます。
void *getFunction(void* lib, void* fname)
{
// Whatever
}
void myFunction( void* (*ptrFunc)(void*, void*) )
{
// void *lib = something;
// void *fname = something else;
ptrFunc(lib, fname);
}
int main()
{
void* (*ptrFunc)(void*, void*) = &getfunction;
// Passing the actual function pointer to another function
myFunction(ptrfunc);
}