Address of function main() in C/C++

后端 未结 3 1378
一生所求
一生所求 2021-01-06 00:33

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 ?

3条回答
  •  迷失自我
    2021-01-06 01:10

    I wasn't 100% sure whether the question was meant from within a program using C/++ or to retrieve address of the main() function created with C/C++ (meaning from the command line).

    Since it looks like you've received several good answers on how to get the address from within the program, I thought I'd mention you can get this info from nm as well.

    nm program|grep main
    

提交回复
热议问题