I've been trying a way to figure out how to print the address of the function, This is what I came up with
#include<stdio.h>
int test(int a, int b)
{
return a+b;
}
int main(void)
{
int (*ptr)(int,int);
ptr=&test;
printf("The address of the function is =%p\n",ptr);
printf("The address of the function pointer is =%p\n",&ptr);
return 0;
}
It o/p something like this without any warning and errors
address of function is =0x4006fa
address of function pointer is =0x7fffae4f73d8
My question whether using %p format specifier is the correct way to print the address of the function or is there any other way to do so?