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