#include <math.h>
#include <stdio.h>
#include <stdlib.h>
struct init
{
char *fname;
double (*fnct)(double);
};
struct init arith_fncts[] = {
{"sin",sin},
{"cos",cos},
{"tan",tan},
{"log",log},
{"exp",exp},
{"sqrt",sqrt},
{0,0}
};
int main()
{
struct init *p;
*p = arith_fncts[0]; /* 错误就在这!!!
* change ==>
* p = &arith_fncts[0]; */
printf("sin:%g\n",(*(p->fnct))(1.2));
return 0;
}
|