#include <stdio.h>
#include <stdlib.h>

typedef void (* PF)();

void add(int a,int b,int *result)
{
   *result=a+b;
   printf("result:%d\n",*result);
}

void main()
{
	int x,y,z;

	PF pfun = add;
	x=5;
	y=4;	
	pfun(x,y,&z);
}

typedef void (* PF)();  换成 typedef void (* PF)(int,int,...);  typedef void (* PF)(,...);   typedef void (* PF)(int,int,int*); 都可以

但是换成  typedef void (* PF)(...);    typedef void (* PF)(int);  不可以。

说明可变形参可以采用直接不指定()或指定前几个再加省略号的形式,直接加省略号不可以,省略号前面必须有逗号。如果指定了确定个的形参,那么就必须与所指向的函数的形参一致。

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2021-04-15
  • 2021-07-01
  • 2022-01-04
  • 2021-09-08
  • 2022-01-26
猜你喜欢
  • 2022-12-23
  • 2021-06-08
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案