Home >Backend Development >C++ >Address of function in C or C++
In C or C, variables are stored in memory, so we can get their memory addresses. Likewise, functions are stored in memory, so they also have some address. To get the address we can just use the function name without the brackets.
Please check the following procedure to get a clear idea.
#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
The above is the detailed content of Address of function in C or C++. For more information, please follow other related articles on the PHP Chinese website!