当前位置:网站首页>C (pointer-02)
C (pointer-02)
2022-06-10 19:10:00 【Fate friend I】
Make progress every day , Make progress !! Thank myself 
List of articles
1
(* ( void(*)() ) 0 )
//void(*)()- Function pointer type
// hold 0 Force type to :void(*)() Function pointer type -0 Is the address of a function
2
void(* signal( int , void(*)(int) ) )(int)
// Simplify the method
typedef void(* pfun_t)(int);
pfun_t signal(int,pfun_t);
//signal It's a function declaration
//signal The arguments to the function are 2 individual , The first is int, The second is function pointers , The parameter the function pointer points to is Int, The return type is void
//signal The return type of a function is also a pointer , The function parameter pointed to by this pointer is int, The return type is void

🪬🪬 Function pointer array usage : Transfer table
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};
// An array of function pointers
int(*pArr[5])(int ,int);
// A pointer to an array of function pointers
int(*(PPArr)[5](int,int))=&pArr;
return 0;
}
practice
char* my_strcpy(cahr* dest,const char* src);
//1 Write a function pointer Pf, Can point to my_strcy
char*(*pf)(char*,const char*);
//2 Write an array of function pointers pfArr, Be able to store 4 individual my_strcy Address of function
cha*(*pfarr[4])(cahr*,const char*);
Callback function :
A callback function is a function called through a function pointer , If you put a pointer to a function ( Address ) Pass as argument to another function , When this pointer is used to call the function it refers to , Let's just say this is a callback function . The callback function is not called directly by the function's implementer , It is called by another party when a specific event or condition occurs , Used to respond to the event or condition .
边栏推荐
- 第一章 SQL操作符
- Adobe Premiere foundation - opacity (mixed mode) (XII)
- 2022.05.29(LC_6079_价格减免)
- 【杂谈】恭喜自己获得CSDN专家称号,努力终会换来结果
- Adobe Premiere基礎-工具使用(選擇工具,剃刀工具,等常用工具)(三)
- MySQL index invalidation scenario
- lingo12软件下载及lingo语言入门资源
- Linked List
- HelloWorld example of TestNG and how to run it from the command line
- Adobe Premiere基础-介绍,配置,快捷键,创建项目,创建序列(一)
猜你喜欢

Adobe Premiere Basic - tool use (select tools, rasoir tools, and other Common Tools) (III)

AEC: analysis of echo generation causes and echo cancellation principle

调试的技巧

Cross domain error: when allowcredentials is true, allowedorigins cannot contain the special value "*“

5. Golang泛型与反射

Adobe Premiere基础-导入导出,合并素材,源文件编译,脱机(二)

How to correctly understand the real-time nature of Bi?

超级简单的课程设计ssm学生管理系统(含源码简单添加、删除、修改、查询操作)

WordPress 6.0 “Arturo阿图罗” 发布

Low carbon data center construction ideas and future trends
随机推荐
Adobe Premiere basic special effects (card point and transition) (IV)
Openssl1.1.1 VS2013-编译教程
[kuangbin]专题二十二 区间DP
基于SSM流量计量云系统的设计与实现.rar(论文+项目源码)
How to transform digital transformation? Which way?
Nodejs judge system type get host name execute console command Chinese garbled code
MySQL高级篇第一章(linux下安装MySQL)【上】
[vulnhub range] janchow: 1.0.1
数据治理经典6大痛点?这本书教你解决
SQL function
WordPress 6.0 “Arturo阿图罗” 发布
跨域报错:When allowCredentials is true, allowedOrigins cannot contain the special value “*“
Low carbon data center construction ideas and future trends
RK1126 新添加一个模块
WordPress 6.0 "Arturo Arturo" release
Chapter 1 SQL operators
OPENCV 检测人脸 不依赖于任何第三方库
第161章 SQL函数 YEAR
Introduction to ad18 device library import
mysql8.0(新特性小结)