程序:
#include <stdio.h>
void func()
{
int i = 1;
}
int main()
{
printf("%p\n",main);
printf("%p\n",*main);
printf("%p\n",**main);
printf("%p\n",***main);
printf("%p\n",func);
printf("%p\n",*func);
printf("%p\n",**func);
printf("%p\n",***func);
return 0;
}
結果:
eagle@eagle-QJC4:~$ ./a.out
4195652
4195652
4195652
4195652
4195638
4195638
4195638
4195638
以下答案來自http://blog.chinaunix.net/uid-10314004-id-2964074.html6.3.2.1 Lvalues, arrays, and function designators
4 A function designator is an expression that has function type. Except when it is the
operand of the sizeof operator, the _Alignof operator, or the unary & operator, a
function designator with type ‘‘function returning type’’ is converted to an expression that
has type ‘‘pointer to function returning type’’.
6.5.3.2 Address and indirection operators
4 The unary * operator denotes indirection. If the operand points to a function, the result is
a function designator; if it points to an object, the result is an lvalue designating the
object. If the operand has type ‘‘pointer to type’’, the result has type ‘‘type’’. If an
invalid value has been assigned to the pointer, the behavior of the unary * operator is
undefined.
function designator 會自動轉換成 pointer to function, 加一個 * 之後變成 function designator ,然後又自動轉換成 pointer to function,周而復始,無論你加多少 * ,最後拿到的還是一個 pointer to function 。