c - c 中的指针和函数

标签 c

请考虑以下代码

#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)()是什么?是函数、变量还是什么?

最佳答案

流量spiral rule :

                 +------+
                 |      |
                 |  +-+ |
                 |  ^ | |            
             int ( *p ) ()
               ^ |    | |
               | +----+ |
               +--------+

               Identifier p
                 is a pointer to..
                 is a pointer to a function  
                 is a pointer to a function returning int

关于c - c 中的指针和函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18810308/

相关文章:

c - 当我知道 char 数组的最大大小时使用 malloc

c - 缺少分隔符。使用 C 中的 Makefile 停止错误

c - 多管道实现。不工作

c - 任何人都知道为什么这个 C 代码不能编译?

python - 使 printf 出现在共享对象库的标准输出中

在 C 中使用 for 循环创建链表并赋值

c - 如何知道使用C、Linux、Socket的服务器的各个IP地址?

c - c 困惑中的命名空间范围

c - 在 C 中使用 malloc 保留内存

c - Printf 参数顺序被忽略