当前位置:网站首页>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] programming logic
- cavans实现静态滚动弹幕
- 2022/07/25 ------ arrangement of strings
- json_object_put: Assertion `jso->_ref_count > 0‘ failed.Aborted (core dumped)
- canvas上传图片base64-有裁剪功能-Jcrop.js
- Write to esp8266 burning brush firmware
- Redis Docker实例与数据结构
- vscode上使用anaconda(已经配置好环境)
- Wechat official account release reminder (wechat official account template message interface)
- Introduction to data analysis | kaggle Titanic mission
猜你喜欢

多目标优化系列1---NSGA2的非支配排序函数的讲解

Tradingview 使用教程

MLX90640 红外热成像仪测温传感器模块开发笔记(六)红外图像伪彩色编码

抓包工具fiddler和wireshark对比

Okaleido ecological core equity Oka, all in fusion mining mode

Dynamically determine file types through links

Uniapp uses the simple method signalr (only for web debugging, cannot package apps)
![[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间](/img/e7/a48bb5b8a86cbc4cd5b37bb16661a8.png)
[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间

Tradingview tutorial

vscode上使用anaconda(已经配置好环境)
随机推荐
[Halcon vision] polar coordinate transformation
畅听,网文流量竞争的下一站?
数据分析入门 | kaggle泰坦尼克任务(一)—>数据加载和初步观察
.NET5WTM(ASP.NET Core) PGSql开箱操作
[Halcon vision] Fourier transform of image
[Halcon vision] image filtering
Introduction to data analysis | kaggle Titanic mission
Datav beautiful data screen production experience
[leetcode每日一题2021/2/13]448. 找到所有数组中消失的数字
Some web APIs you don't know
Prevent XSS attacks
[leetcode每日一题2021/4/23]368. 最大整除子集
[socket] the three handshakes are completed in listen, and accept only takes out one connection from the queue that completes the connection
卸载魅族应用商店
Our Web3 entrepreneurship project is yellow
string null转空字符串(空字符串是什么意思)
码云,正式支持 Pages 功能,可以部署静态页面
数据库函数
About the declaration and definition of template functions [easy to understand]
粽子大战 —— 猜猜谁能赢