gpt4 book ai didi

纯 C 中的回调函数

转载 作者:太空宇宙 更新时间:2023-11-04 02:49:30 29 4
gpt4 key购买 nike

<分区>

我正在以这种方式实现回调函数:

typedef void (*callback)()

它工作正常,我可以将参数传递给此类回调:

void Call(int X){
printf("Input: %d", X);
}
void PrintSomething(callback F){
printf("Something");
F(10);
}

但我无法摆脱我做错事的感觉。我的方法内存安全吗?还有其他用参数实现回调函数的好方法吗?

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com