当前位置:网站首页>c(指针-02)
c(指针-02)
2022-06-10 18:16:00 【缘友一世】
每天进步一点,进步一点!!感谢自己
文章目录
1
(* ( void(*)() ) 0 )
//void(*)()-函数指针类型
//把0强制类型转换成:void(*)() 函数指针类型 -0就是一个函数的地址
2
void(* signal( int , void(*)(int) ) )(int)
//简化方法
typedef void(* pfun_t)(int);
pfun_t signal(int,pfun_t);
//signal是一个函数声明
//signal函数的参数有2个,第一个是int,第二个是函数指针,该函数指针指向的参数是Int,返回类型是void
//signal函数的返回类型也是一个指针,该指针指向的函数参数是int,返回类型是void

🪬🪬函数指针数组用途:转移表
int Add(int x,int y)
{
int z=x+y;
return z;
}
int main()
{
int a=10;
int b=10;
int(*pa)(int,int)=Add;
printf("%d\n",pa(2,3));
printf("%d\n",Add(2,3));
printf("%d\n",(*pa)(2,3));
return 0;
}
int Add(int x,int y)
{
return x+y;
}
int Sub(int x,int y)
{
return x-y;
}
int Mul(int x,int y);
{
return x*y;
}
int Div(int x,int y)
{
return x/y;
}
int main()
{
int *arr[4];
int(*parr[4])(int ,int)={
Add,Sub,Mul,Div};
//函数指针的数组
int(*pArr[5])(int ,int);
//指向函数指针数组的指针
int(*(PPArr)[5](int,int))=&pArr;
return 0;
}
练习
char* my_strcpy(cahr* dest,const char* src);
//1写一个函数指针Pf,能够指向my_strcy
char*(*pf)(char*,const char*);
//2写一个函数指针数组pfArr,能够存放4个my_strcy函数的地址
cha*(*pfarr[4])(cahr*,const char*);
回调函数:
回调函数就是一个通过函数指针调用的函数,如果你把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用来调用其所指的函数时,我们就说这是回调函数。回调函数不是由该函数的实现方直接调用,而是在特定的事件或条件发生时有另外的一方调用的,用于对该事件或条件进行相应。
边栏推荐
- libcurl 7.61.0 VS2013 编译教程
- Adobe Premiere foundation - opacity (matte) (11)
- JS Touch
- 【代理】10分钟掌握正向代理和反向代理的本质区别
- Adobe Premiere基礎-工具使用(選擇工具,剃刀工具,等常用工具)(三)
- In 2021, the world's top ten analog IC suppliers: Ti ranked first, and skyworks' revenue growth was the highest
- nodejs-基本架构分析-解析引擎目录-插件安装-核心模块
- What is Bi? Talk about the definition and function of Bi
- [database language SPL] a simple and fast database language SPL
- MySQL index invalidation scenario
猜你喜欢

腾讯云数据库TDSQL-大咖论道 | 基础软件的过去、现在、未来

Upgrade the playing method of snatching singing, integrate the climax clips of genuine music and real-time scoring ability~

Adobe Premiere基础-素材嵌套(制作抖音结尾头像动画)(九)

Leecode27977 double finger needling

How to play the Dragon Boat Festival "immersive cloud Tour"? That is to say, it helps "live broadcast +" new scene landing

Adobe Premiere基础-介绍,配置,快捷键,创建项目,创建序列(一)

Pits encountered during the use of ETL (ETL Chinese garbled)

SaleSmartly | 再添新渠道Slack,助你拉近客户关系

TestNG的HelloWorld例子以及如何在命令行下运行

Adobe Premiere Basic - tool use (select tools, rasoir tools, and other Common Tools) (III)
随机推荐
In the era of data processing, data analysis has become the basic construction
Libcurl 7.61.0 vs2013 compilation tutorial
[vulnhub range] janchow: 1.0.1
Google Earth engine (GEE) -- Copernicus atmosphere monitoring (CAMs) global aerosol AOI near real-time observation data set
How to set up salesmartly for Google Analytics tracking
Adobe Premiere基础(动画制作-弹性动画)(八)
How to correctly understand the real-time nature of Bi?
Adobe Premiere foundation - Import and export, merge materials, source file compilation, offline (II)
The value of Business Intelligence BI. Is visual report equal to Business Intelligence BI?
第一章 SQL操作符
Db2 SQL PL的锚点类型和行数据类型
Enterprise data quality management: how to evaluate data quality?
AgI foundation, uncertain reasoning, subjective logic ppt2
Jsp基于ssm项目实验室管理系统设计与现实.doc
Pits encountered during the use of ETL (ETL Chinese garbled)
《Single Image Haze Removal Using Dark Channel Prior》去雾代码实现分析
【杂谈】恭喜自己获得CSDN专家称号,努力终会换来结果
【Vulnhub靶场】JANGOW: 1.0.1
最长上升子序列(LIS)洛谷
单纯形法代码求解(含超详细代码注释和整个流程图)