Home > Backend Development > C++ > Address of function in C or C++

Address of function in C or C++

WBOY
Release: 2023-08-27 19:05:02
forward
855 people have browsed it

C 或 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.

Example

#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);
}
Copy after login

Output

The address of the my_function is: 0000000000401530
The address of the main is: 000000000040154B
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template