函数指针就像atexit一样,我们不需要声明和定义函数 [英] function pointer like atexit which we have no need to declare and define the function

查看:110
本文介绍了函数指针就像atexit一样,我们不需要声明和定义函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有像atexit这样的函数,其中不需要声明和定义函数指针我们只应该传递函数(就像atexit函数一样)?

解决方案

< blockquote>我不确定你的意思。你必须使用返回void的void参数传递atexit函数的地址。


现在,函数的名称是函数的地址,所以你只需传递函数名到atexit。永远不需要定义实际的函数指针变量。


是的我想要另一个内置函数就像atexit一样,我想在其中传递函数名称并且需要声明函数指针


你能给出你想做的代码示例吗?


内置函数是不是没关系或者,如果它有一个函数指针参数,你需要做的就是传入函数的名称。


Is there are any function like atexit in which there is no need to declare and define function pointer we only should pass the function(just like atexit function)?

解决方案

I''m not sure what you mean. You have to pass atexit the address of a function with void arguments that returns void.

Now, the name of a function is the address of the function so you can just pass the function name to atexit. There is never any need to define an actual function pointer variable.


Yeah I want another inbuilt function just like atexit,in which I want to just pass the function name and there shud be need to declare function pointer


Can you give a code example of what you want to do?

It doesn''t matter if a function is inbuilt or not, if it has a function pointer argument all you need to do is pass in the name of the function.


这篇关于函数指针就像atexit一样,我们不需要声明和定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆