C 地址函数指针 结构体数组 初始化

#include <stdio.h>
#include <math.h>

#define PI 3.14159265

static void math_test_acos(){
    double x,ret,val;
    x=0.9;
    val=180.0/PI;
    ret=acos(x) * val;
    printf("%f 的反余弦是 %lf 度\n",x,ret);
}

typedef void (*mathTest_func)();

typedef struct{
    const char *name;
    const mathTest_func func;
} mathTest_method_info;

static const mathTest_method_info test_methods[]={
    {"acos",math_test_acos},
    {NULL,NULL}
};


int main(){
char *name="aa";
 int i=0;
 test_methods[i++].func();
 
 return 0;
}


猜你喜欢

转载自blog.csdn.net/z278718149/article/details/86470437