c-46 函数指针 和 函数指针数组

#include <stdio.h>
void function1()
{
 printf("函数一 没有参数和 返回值");

}

void function2(char str[2222])
{
 printf("%s 函数二  有参数 无返回值", str);
}


int  function3(int a, int b)
{
 printf("函数三  有参数和返回值");
 return a + b;
}

int function4(int a,int b)
{
 return a * b;
}
int main(int argc, char* argv[])
{
 
 void(*p1)() = function1;
 void(*p2)(char[]) = function2;
 int(*p3)(int, int) = function3;

 int(*p4[])(int, int) = { function4,function3 };
 
 printf("p4 = %d \n", p4[0](2, 3));

 printf("p3 = %d \n", p4[1](2, 3));
 getchar();
 return 0;
}

posted @ 2018-06-23 00:23  zhumoerju  阅读(96)  评论(0)    收藏  举报