当前位置:网站首页>Struct function & function pointer
Struct function & function pointer
2022-07-03 11:10:00 【MrPeng1991】
#include<stdio.h>
#include<stdlib.h>
// Structure function
struct str_func{
int a;
int b;
int (*add)(int a,int b);// A function pointer , It's essentially a pointer variable , Point to the function address ,
int(*sub) (int a, int b);
int (*compare)(int a, int b);
};
// A function pointer
int add(int a,int b){
return a+b ;
}
int sub(int a,int b){
return a-b;
}
int compare(int a, int b){
if (a>b){
return a;
}
else
return b;
}
struct str_func test = {
.a=5,
.b=7,
.add=add,
.sub = sub,
.compare = compare,
};
int main(){
if (test.compare){
printf("a b max=%d\n",(test.compare(test.a,test.b)));
};
if (test.compare){
printf("a add b =%d\n",(test.add(test.a,test.b)));
};
if (test.compare){
printf("a b max=%d\n",(test.sub(test.a,test.b)));
};
}
边栏推荐
- The element form shows the relationship between elementary transformation and elementary matrix
- Use ml.net+onnx pre training model to liven the classic "Huaqiang buys melons" in station B
- Google Earth Engine(GEE)——GHSL 全球人口网格数据集250米分辨率
- 线性表顺序表综合应用题P18
- The solution that prompts "system group policy prohibits the installation of this device" under win10 system (home version has no group policy)
- 2022 pinduogai 100000 sales tutorial
- Software testing e-commerce projects that can be written into your resume, don't you come in and get it?
- 8年测试总监的行业思考,看完后测试思维认知更深刻
- Cause: org. apache. ibatis. builder. Builderexception: error parsing SQL mapper configuration problem analysis
- Communication software development and Application
猜你喜欢
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
QT: QSS custom qtableview instance
我,大厂测试员,降薪50%去国企,后悔了...
Stack, monotone stack, queue, monotone queue
字节跳动大裁员,测试工程师差点遭团灭:大厂招人背后的套路,有多可怕?
Expandablelistview that can expand and shrink (imitating the list page of professional selection of Zhilian recruitment)
最高月薪18K 拥有好的“心态和选择”, 成功就差“认真和坚持”~
php服务器 与redis交互大量CLOSE_WAIT分析
游戏测试相关 测试一个英雄的技能(春招被问比较多的一道题)
Que se passe - t - il ensuite pour ceux qui se sont concentrés sur les tests automatisés?
随机推荐
Do you really need automated testing?
Differences among norm, normalize and normalized in eigen
嵌入式軟件測試怎麼實現自動化測試?
Summary of the history of Mathematics
IIS修改配置信息后不生效
Que se passe - t - il ensuite pour ceux qui se sont concentrés sur les tests automatisés?
QT: QSS custom qtoolbutton instance
Matlab memory variable management command
Some abilities can't be learned from work. Look at this article, more than 90% of peers
Oracle收回权限 & 创建角色
Hard goods | write all the codes as soon as you change the test steps? Why not try yaml to realize data-driven?
【Proteus仿真】74HC154 四线转12线译码器组成的16路流水灯
Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
2021 reading summary (continuously updating)
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
[true question of the Blue Bridge Cup trials 44] scratch eliminate the skeleton Legion children programming explanation of the true question of the Blue Bridge Cup trials
Clion debug
测试Leader应该做哪些事
Communication software development and Application
UI自动化测试如何走出困境?价值又如何体现?