Why does printing a function name returns a value?

后端 未结 3 1861
野趣味
野趣味 2021-01-12 15:41

I accidentally printed a function name without the parenthesis and it printed a value. I am just curious about how this happens? Output is same irrespective of the function

3条回答
  •  醉梦人生
    2021-01-12 16:08

    This statement printf("\n%u", foo); passes the address of function foo() to printf. So the value that gets printed is the address of this function in the memory of the running program.

提交回复
热议问题