在C或C++中,变量存储在内存中,因此我们可以获得它们的内存地址。同样,函数也存储在内存中,因此它们也有一些地址。要获取地址,我们可以只使用函数名称,而不使用括号。
请检查以下程序以获得清晰的想法。
#include <stdio.h> void my_function() { printf("Hello World"); } int main() { printf("The address of the my_function is: %p\n", my_function); printf("The address of the main is: %p\n", main); }
The address of the my_function is: 0000000000401530 The address of the main is: 000000000040154B
以上就是C 或 C++ 中函数的地址的详细内容,更多请关注php中文网其它相关文章!
c++怎么学习?c++怎么入门?c++在哪学?c++怎么学才快?不用担心,这里为大家提供了c++速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号