卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章64334本站已运行4115

C 或 C++ 中函数的地址

C 或 C++ 中函数的地址

在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语言中,如果在函数声明之前调用函数会发生什么?
下一篇: 打印N行数字,使得每对数字之间的最大公约数为K
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏