当前位置:网站首页>C language callback function
C language callback function
2022-07-26 10:36:00 【Qingyun -- Xiaofan】
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <curl/curl.h>
#include <pthread.h>
#ifdef WIN32
# include <io.h>
# define READ_3RD_ARG unsigned int
#else
# include <unistd.h>
# define READ_3RD_ARG size_t
#endif
#if LIBCURL_VERSION_NUM < 0x070c03
#error "upgrade your libcurl to no less than 7.12.3"
#endif
void* cb(void *arg)
{
printf("call back function, pid=%ld\n", pthread_self());
return NULL;
}
void fun1(void)
{
printf("fun1 call\n");
return;
}
void fun2(int a)
{
printf("fun2 call a=%d\n", a);
return;
}
void fun3(int a, double b)
{
printf("fun3 call a=%d,b=%lf\n", a, b);
return;
}
int fun4(void)
{
printf("fun4 call back\n");
return 666;
}
int* fun5(int a)
{
int* ptr = NULL;
ptr = &a;
printf("fun5 call bacl a=%d\n", a);
return ptr;
}
int main(void)
{
pthread_t therad1;
pthread_create(&therad1, NULL, cb, NULL);
pthread_join(therad1, NULL);
pthread_t thread2;
pthread_create(&thread2, NULL, cb, NULL);
pthread_join(thread2, NULL);
void (*ptr)(void); // ptr Is a function pointer with no return value and no parameters
ptr = fun1;
ptr();
(*ptr)();
void (*ptr2)(int); // ptr2 Is a function pointer with no return and one parameter
ptr2 = fun2;
ptr2(666);
void (*ptr3)(int, double);
ptr3 = fun3;
ptr3(12, 234.321);
int (*ptr4)(void);
ptr4 = fun4;
int rtn = ptr4();
printf("rtn=%d\n", rtn);
int* (*ptr5)(int);
ptr5 = fun5;
rtn = *ptr5(888); // ptr5 Express int* Function pointer of type , Assign to a int Type variables need to be dereferenced before they can be used
printf("rtn=%d\n", rtn);
return 0;
}边栏推荐
- [Halcon vision] threshold segmentation
- mysql 进不去了怎么办
- Centos8 (liunx) deploying WTM (asp.net 5) using PgSQL
- 卸载魅族应用商店
- C语言计算日期间隔天数
- Function templates and non template functions with the same name cannot be overloaded (definition of overloads)
- The software cannot be opened
- Navicat15 MySQL (centos7) connected to local virtual machine
- 图片随手机水平移动-陀螺仪。360度设置条件
- STM32 阿里云MQTT esp8266 AT命令
猜你喜欢

【dectectron2】跟着官方demo一起做
![[Halcon vision] image filtering](/img/7a/b95f8977f02fab644ef9fb205424e7.png)
[Halcon vision] image filtering
![Structure of [Halcon vision] operator](/img/d9/e16ea52cea7897e3a1d61d83de472f.png)
Structure of [Halcon vision] operator
![[Halcon vision] morphological corrosion](/img/f9/f01dd3340824ff28c84cf7bb52882e.png)
[Halcon vision] morphological corrosion

Unit test, what is unit test and why is it so difficult to write a single test

Navicat15 MySQL (centos7) connected to local virtual machine

404页面和路由钩子

【机器学习小记】【人脸识别】deeplearning.ai course4 4th week programming

Application of.Net open source framework in industrial production
![[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】](/img/13/c6cb176d7065035f60d55ad20ed1bf.png)
[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】
随机推荐
uniapp使用简单方法signalR(仅用于web调试,无法打包app)
.net operation redis list list
并行、并发及对于高并发优化的几个方向
SAP ABAP Netweaver 容器化的一些前沿性研究工作分享
Mlx90640 infrared thermal imager temperature sensor module development notes (VI) pseudo color coding of infrared images
第4期:大学生提前职业技能准备之一
.NET操作Redis Set无序集合
[leetcode每日一题2021/2/14]765. 情侣牵手
What is wrong about the description of function templates (how to solve link format errors)
Uniapp uses the simple method signalr (only for web debugging, cannot package apps)
一些你不知道的 web API
单元测试,到底什么是单元测试,为什么单测这么难写
数据库函数
议程速递 | 7月27日分论坛议程一览
json_object_put: Assertion `jso->_ref_count > 0‘ failed.Aborted (core dumped)
Introduction to Phoenix (Level 1: Phoenix installation, level 2: Phoenix basic grammar)
[Halcon vision] array
PLC overview
hx711 数据波动大的问题
.NET 开源框架在工业生产中的应用