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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C编程
C++
C#
MongoDB
MySQL
Javascript
PHP