so the function pointer should point to something like
void * process(void * data)
{
}
i tried sthing like
(void *) (function *)(void *)
but doesnt work!!!
opinions and view please ( even solutions will do... )
|
Newbie Member
|
|
| 6Dec2007,18:45 | #1 |
|
How do u declare a function pointer which takes a void pointer and returns a void pointer.
so the function pointer should point to something like void * process(void * data) { } i tried sthing like (void *) (function *)(void *) but doesnt work!!! opinions and view please ( even solutions will do... )
|
|
Ambitious contributor
|
|
| 6Dec2007,21:26 | #2 |
|
You were pretty close!
Code:
#include <stdio.h>
void *foo ( void *msg ) {
printf( "%s\n", msg );
return msg;
}
typedef void *(*fnptr)(void*);
int main ( ) {
void * (*f1)(void*) = foo;
fnptr f2 = foo;
f1( "hello" );
f2( "world" );
return 0;
}
Also read this - http://www.newty.de/fpt/index.html |