// File name: c_callback_funtions_void.c
# Include <stdio. h>
# Include <stdlib. h> // exit ()
# Include <string. h> // bzero ()
# Include <sys/time. h>
# Include <sys/types. h>
# Include <unistd. h>
Typedef void taskfunc (void * argument );
Void do_something (taskfunc * proc, void * argument)
{
(* Proc) (argument); // The function is called here.
}
Void funtion_1 (void * argument)
{
Char * P = (char *) argument;
Printf ("funtion_1 print is: % s/n", P );
}
Typedef struct _ for_funtion2
{
Int;
Char STR [20];
} For_funtion2;
Void funtion_2 (void * argument)
{
For_funtion2 * P = (for_funtion2 *) argument;
Printf ("funtion_2 print is: % d, % s/n", p-> A, P-> Str );
}
Int main (INT argc, char * argv [])
{
Char str1 [] = "this is funtion_1 ";
/* Method 1 */
Void * argument_fun_1 = (void *) str1;
Do_something (& funtion_1, argument_fun_1 );
/* Method 2 */
Do_something (& funtion_1, (void *) str1 );
For_funtion2 * P = (for_funtion2 *) malloc (sizeof (for_funtion2 ));
P-& gt; A = 100;
Memcpy (p-> STR, "this is funtion_2/0", sizeof ("this is funtion_2 "));
/* Method 1 */
Void * argument_fun_2 = (void *) P;
Do_something (& funtion_2, argument_fun_2 );
/* Method 2 */
Do_something (& funtion_2, (void *) P );
Printf ("% d/N", sizeof ("test"); // note that the value is 5
Return 0;
}
Http://www.newty.de/fpt/intro.html
Http://www.cplusplus.com/forum/general/158/