- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the Address of a function in C or C++?
A function is a block of code that is defined to perform a specific piece of work in a program. It is used to ease the work of the programmer by defining a commonly occurring piece of code so that it can be reused when required.
The address is the memory location where the entity is stored. Every block of code in the program has its own memory location in the program. Which means like any variable or object methods and functions also have memory address.
To get the memory address of a function you need to use the pointer of the method and write the name of the function without parentheses.
Example
#include<iostream> using namespace std; void myfunc(){ cout<<"This is myfunc"; } int main(void){ printf("address of function main() is :%p\n", main); printf("address of function myfunc() is : %p\n", myfunc); return 0; }
Output
address of function main() is :0x40079d address of function myfunc() is : 0x400787
Advertisements