Address of a function in C or C++ (original) (raw)
Last Updated : 20 May, 2018
We all know that code of every function resides in memory and so every function has an address like all others variables in the program. We can get the address of a function by just writing the function's name without parentheses. Please refer function pointer in C for details. Address of function main() is 004113C0 Address of function funct() is 00411104 In C/C++, name of a function can be used to find address of function.
C `
// C program to addresses of a functions // using its name #include<stdio.h>
void funct() { printf("GeeksforGeeks"); }
int main(void) { printf("address of function main() is :%p\n", main); printf("address of function funct() is : %p\n", funct); return 0; }
`
Output:
address of function main() is :0x40053c address of function funct() is : 0x400526
Similar Reads
- atexit() function in C/C++ The function pointed by atexit() is automatically called without arguments when the program terminates normally. In case more than one function has been specified by different calls to the atexit() function, all are executed in the order of a stack (i.e. the last function specified is the first to b 3 min read
- asctime() function in C++ The asctime() function is defined in the ctime header file. The asctime() function converts the given calendar time of structure tm to a character representation i.e human readable form. Syntax: char* asctime(const struct tm * time_ptr); Parameter: This function accepts single parameter time_ptr i.e 1 min read
- towupper() function in C/C++ The towupper() is a built-in function in C/C++ which converts the given wide character into uppercase. It is defined within the cwctype header file of C++. Syntax: wint_t towupper( wint_t ch ) Parameter: The function accepts a single mandatory parameter ch which specifies the wide character which we 2 min read
- How to Declare a Pointer to a Function? A pointer to a function is similar to a pointer to a variable. However, instead of pointing to a variable, it points to the address of a function. This allows the function to be called indirectly, which is useful in situations like callback functions or event-driven programming.In this article, we w 2 min read
- strdup() and strndup() functions in C/C++ The strdup() and strndup() functions are used to duplicate a string. strdup() : Syntax : char *strdup(const char *s); This function returns a pointer to a null-terminated byte string, which is a duplicate of the string pointed to by s. The memory obtained is done dynamically using malloc and hence i 2 min read
- strtod() function in C/C++ The strtod() is a builtin function in C and C++ STL which interprets the contents of the string as a floating point number and return its value as a double. It sets a pointer to point to the first character after the last valid character of the string, only if there is any, otherwise it sets the poi 4 min read
- acos() function in C++ STL acos() is an inbuilt function in C++ STL and it’s the same as the inverse of cosine in maths. The acos() function returns the values in the range of [0, π] which is the angle in radians. Syntaxacos(data_type x);ParametersThis function accepts one mandatory parameter x which specifies the value whose 3 min read
- moveto() function in C The header file graphics.h contains moveto() function which changes the current position to (x, y) Syntax : void moveto(int x, int y); Examples : Input : x = 70, y = 40 Output : Input : x = 50, y = 80 Output : Below is the implementation of moveto() function: C // C Implementation for moveto() #incl 2 min read
- list assign() function in C++ STL The list::assign() is a built-in function in C++ STL which is used to assign values to a list. It can also be used to copy elements from one list to another. To assign elements to a list. Syntax: list_name.assign(count, value) Parameters: This function accepts two mandatory parameters as shown in th 2 min read
- array at() function in C++ STL The array::at() is a built-in function in C++ STL which returns a reference to the element present at location i in given array. Syntax: array_name.at(i) Parameters: The function accepts a single mandatory parameter i which specifies the location. Return value: The function returns an element presen 2 min read