C/C++ callback function code example
C/C++回调函数代码实例
JAVA;">
#include
typedef void (*P)(void);
void fun1(void)
{
printf("hello world\n");
}
void fun2(void)
{
printf("cbs\n");
}
int main(void)
{
P p;
p = fun1;
p();
p = fun2;
p();
return 0;
}
JAVA;">
#include
typedef void (*P)(void);
void printf_text(void)
{
printf("hello world\n");
}
void call_printf_text(P p)
{
p();
}
int main(void)
{
P p = printf_text;
call_printf_text(p);
return 0;
}
JAVA;">
#include
typedef void (*P)(const char *);
void printf_text(const char *str)
{
printf("%s\n",str);
}
void call_printf_text(P p,const char *str)
{
p(str);
}
int main(void)
{
P p = printf_text;
call_printf_text(p,"hello cbs");
return 0;
}
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326365585&siteId=291194637
Recommended
Ranking