函数指针的指针:int(**p)(char *)

http://bbs.chinaunix.net/thread-3772418-1-1.html

int(**p)(int *); 如何使用p?强转之。。。

 

 ----------------------

函数就是个地址,如何传参数取决于你赋予它的类型:

#include <stdio.h>
#include <stdlib.h>
double f1(double x)
{
    printf("%s:%f\n",__FUNCTION__,x);
    return x;
}
void *f2(void *a1, void *a2, void *a3)
{
    printf("%s:%s/%s/%s\n",__FUNCTION__,(char *)a1,(char *)a2,(char *)a3);
    return NULL;
}


void *f3(void *a)
{
    printf("%s:%s\n",__FUNCTION__,(char *)a);
    return NULL;
}


int   main()
{
    typedef void(*fun_t)(void *);

fun_t pfun[3] = {(fun_t)f1, (fun_t)f2, (fun_t)f3};

((double(*)(double))pfun[0])(3.14);
((void *(*)(void *, void *, void *))pfun[1])("f2", "f2", "f2");
pfun[2]("f3");

return   0;
}

  

posted @ 2012-09-21 23:36  庄庄庄  阅读(521)  评论(0编辑  收藏  举报