|
|
函数指针:void (*f) ()
函数返回指针:void *f ()
const指针:const int*
指向const的指针:int *const
指向const的const的指针:const int * const
找出下面程序的错误:
int max(int x, int y)
{
return x > y?x:y;
}
int main()
{
int max(x, y);//应该改为int max(int, int);
int *p = &max;//应该改为int (*p)(int, int) = &max;这里注意函数指针的定义和初始化方式。
int a, b, c, d;
printf("please input three integer\n");
scanf("%d%d%d", a,b,c);//应该改为scanf("%d%d%d", &a, &b, &c);
d = (*p)((*p)(a, b), c);
printf("Among %d, %d, and %d, the maxmal integer is %d\n", a, b, c, d);
return 0;
} |
|