Address of function main() in C/C++
问题 Is there a way to find out the address of main() in C or C++ ? Since it is itself a function ,would there be an address of it own ? 回答1: C Sure. Simply go ahead and do it. #include <stdio.h> int main(void) { printf("%p\n", &main); } C++ It is not permitted to take main 's address so, for your purposes, there isn't one: [C++11: 3.6.1/3]: The function main shall not be used within a program. [..] However, in GCC you can take the same approach as you would in C, via a compiler extension: