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