次のコードを検討してください
#include<stdio.h>
int fun(); /* function prototype */
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("IndiaBix.com\n");
return 0;
}
ここには何がint(*p)()
ありますか?それは関数ですか、変数ですか、それとも何ですか?
次のコードを検討してください
#include<stdio.h>
int fun(); /* function prototype */
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("IndiaBix.com\n");
return 0;
}
ここには何がint(*p)()
ありますか?それは関数ですか、変数ですか、それとも何ですか?
フロースパイラル ルール:
+------+
| |
| +-+ |
| ^ | |
int ( *p ) ()
^ | | |
| +----+ |
+--------+
Identifier p
is a pointer to..
is a pointer to a function
is a pointer to a function returning int
int(*p)()
-p
は、何も受け取らず、 を返す関数へのポインタint
です。
したがって、p は c の変数です。