How to print the address of a function?

前端 未结 4 622
旧时难觅i
旧时难觅i 2020-11-29 11:18

I let gcc compile the following example using -Wall -pedantic:

#include 

int main(void)
{
  printf(\"main: %p\\n\",         


        
4条回答
  •  旧时难觅i
    2020-11-29 11:51

    This is essentially the only portable way to print a function pointer.

    size_t i;
    int (*ptr_to_main)() = main;
    for (i=0; i

提交回复
热议问题