C语言中的注册回调函数_onexit()
发布日期:2022-02-10 13:35:53 浏览次数:45 分类:技术文章

本文共 589 字,大约阅读时间需要 1 分钟。

_onexit(func)

在MFC就经常看到回调函数,想不到在C语言中也有。

函数功能:

注册一个退出回调函数。

返回值:

成功返回一个指针,否则返回NULL。

参数:

回调函数的指针。

例子:

#include 
#include
int fn1(void), fn2(void), fn3(void), fn4 (void);void main( void ){ _onexit( fn1 ); _onexit( fn2 ); _onexit( fn3 ); _onexit( fn4 ); printf( "This is executed first.\n" );}int fn1(){ printf( "next.\n" ); return 0;}int fn2(){ printf( "executed " ); return 0;}int fn3(){ printf( "is " ); return 0;}int fn4(){ printf( "This " ); return 0;}
输出:

This is executed first.This is executed next

详细使用可以搜索MSDN。

一句话解释:

onXXX()基本都是消息处理函数。

转载地址:https://blog.csdn.net/zoopang/article/details/24604575 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:TCP/IP协议复习-概述
下一篇:C/C++中的预定义宏

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月03日 04时48分00秒