当前位置:网站首页>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;
}边栏推荐
- .NET5WTM(ASP.NET Core) PGSql开箱操作
- The difference between equals and = =
- 微信公众号发布提醒(微信公众号模板消息接口)
- 10 令 operator= 返回一个 reference to *this
- 抓包工具fiddler和wireshark对比
- 2022/07/25------字符串的排列
- [leetcode每日一题2021/8/31]1109. 航班预订统计【中等】差分数组
- [leetcode每日一题2021/2/14]765. 情侣牵手
- 将json文件中数组转换为struct
- Kaptcha image verification code integration
猜你喜欢

Problems encountered in QRcode QR code (C language)
![[Halcon vision] software programming ideas](/img/9b/a27338689ee4598dac88f6e5d92053.png)
[Halcon vision] software programming ideas
![[Halcon vision] morphological expansion](/img/ce/abaca036fce5b67dfe6ac361aecfea.png)
[Halcon vision] morphological expansion

Tradingview tutorial

videojs转canvas暂停、播放、切换视频

The difference between equals and = =
The software cannot be opened

Navicat15 MySQL (centos7) connected to local virtual machine

码云,正式支持 Pages 功能,可以部署静态页面

Redis Docker实例与数据结构
随机推荐
单元测试,到底什么是单元测试,为什么单测这么难写
404页面和路由钩子
canvas上传图片base64-有裁剪功能-Jcrop.js
js翻页、kkpager.js翻页
Closure of go (cumulative sum)
[Halcon vision] programming logic
粽子大战 —— 猜猜谁能赢
hx711 数据波动大的问题
[Halcon vision] morphological corrosion
.NET操作Redis List列表
centos8(liunx)部署WTM(ASP.NET 5)使用pgsql
Introduction to data analysis | kaggle Titanic mission
Navicat15连接本地虚拟机的Mysql(Centos7)
Google与Pixar开发Draco支持USD格式 加速3D对象传输&lt;转发&gt;
Modelsim installation tutorial (application not installed)
L2-005 集合相似度(vector、set求并交集)
[C language] LINQ overview
[gossip] error loading psychopg2 module: no module named psychopg2
[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】
Redis Docker实例与数据结构