69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
typedef struct test_t
{
int count;
int (*funhook)(struct test_t*);
}test_t;
test_t *mytmp;
int fun(test_t *mytmp)
{
printf("fun::count=%d\n",mytmp->count);
return mytmp->funhook(mytmp);
}
int fun2(test_t *mytmp)
{
printf("fun2::count=%d\n",++(mytmp->count));
return;
}
int main(int argc,char **argv)
{
mytmp = (test_t*)malloc(sizeof(test_t));
mytmp->count = 1;
mytmp->funhook = fun2;
fun(mytmp);
printf("main::%d\n",mytmp->count);
free(mytmp);
return 0;
}