当前位置:网站首页>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 role and necessity of implementing serializable interface
- 读书笔记:《心若菩提》 曹德旺
- I have been doing software testing for three years, and my salary is less than 20K. Today, I put forward my resignation
- 图解网络:什么是虚拟路由器冗余协议 VRRP?
- File upload and download test point
- Matlab memory variable management command
- A simple method of adding dividing lines in recyclerview
- What kind of living condition is a tester with a monthly salary of more than 10000?
- Definition and properties of summation symbols
- php如何解决高并发问题
猜你喜欢

Is it OK to test the zero basis software?

11. Provider service registration of Nacos service registration source code analysis

独家分析 | 关于简历和面试的真 相

8年测试工程师总结出来的《测试核心价值》与《0基础转行软件测试超全学习指南》

php服务器 与redis交互大量CLOSE_WAIT分析

Activity and fragment lifecycle

Crawl with requests

我对测试工作的一些认识(资深测试人员总结)

The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~

17K薪资要什么水平?来看看95后测试工程师的面试全过程…
随机推荐
2022 pinduogai 100000 sales tutorial
公司里只有一个测试是什么体验?听听他们怎么说吧
Crawl with requests
Using activity to realize a simple inputable dialog box
Qt:qss custom qgroupbox instance
Google Earth Engine(GEE)——GHSL 全球人口网格数据集250米分辨率
硬 货 | 一改测试步骤代码就全写?为什么不试试用 Yaml实现数据驱动?
Oracle收回权限 & 创建角色
The role and necessity of implementing serializable interface
Inexplicable problems in the nesting of constraintlayout and relativelayout
[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
嵌入式软件测试怎么实现自动化测试?
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder
软件测试工程师的5年之痒,讲述两年突破瓶颈经验
What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers
Qt:qss custom qlistview instance
The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~
Internet Socket (非)阻塞write/read n个字节
Qt:qss custom qscrollbar instance
做软件测试三年,薪资不到20K,今天,我提出了辞职…