在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++ 中函数的地址的详细内容。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)