首页 > 编程语言 > 详细

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

时间:2018-06-23 01:07:51      阅读:271      评论:0      收藏:0      [点我收藏+]

#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;
}

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

原文:https://www.cnblogs.com/sinianxinfei/p/9216077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!