address of functions

closed account (z0XLy60M)
Like variables, do functions also have addressees...?

if so..then how can find it..?
They do (sort of). If you want to, you can think of the address of the function as the address of the first instruction.

To get it, just use the & operator like normal:

some_func_ptr = &my_func;
closed account (z0XLy60M)
Okay, but How exactly can i use this pointer now....?
For example....?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void somefunc()
{

}

typedef void (*functype)(void);

void main()
{
functype func;
func = somefunc;
func(); //calling function somefunc by func
}
Last edited on
Topic archived. No new replies allowed.