Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
int func_s(int){return 1;}
typedef int (*FUNC_C)(int);
FUNC_C f = func_s;   //(1)
FUNC_C f = &func_s;  //(2)

Both (1),(2) compiled OK!(under vs2005).
I just don't know the difference? what's the '&'function in (2)?

thanks in advance.
Posted

1 solution

'For all practical purposes, the name of a function and a pointer to the same function are interchangeable'

http://stackoverflow.com/questions/9552663/function-pointers-and-address-of-a-function[^]

and the link it points to:

http://stackoverflow.com/questions/6893285/why-do-all-these-crazy-function-pointer-definitions-all-work-what-is-really-goi[^]

Use your debugger to confirm this - a good exercise.
 
Share this answer
 
v2
Comments
chandanadhikari 23-Apr-15 3:15am    
5! very precise
[no name] 23-Apr-15 6:38am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900