c - 函数指针 : why is (*fptr)(6, 7) 与 (fptr)(6,7) 相同,如果函数是 add(int , int )

标签 c function pointers

function pointers ,

为什么是(*fptr)(int a, int b)(fptr)(int a, int b) 相同函数指针是否赋值给add函数?

int (*fptr)(int ,int) = add; 
while add(int a , int b) returns sum of two numbers.    

最佳答案

说明

C 没有函数对象,因此取消引用函数指针是没有意义的。因此,当函数指针被取消引用时,它(有一些异常(exception))立即变回函数指针。

引用文献

n1570 (当前C标准的最终公开草案):

6.5.3.2 Address and indirection operators

  1. The unary * operator denotes indirection. If the operand points to a function, the result is a function designator; [...]

...

6.3.2.1 Lvalues, arrays, and function designators

  1. 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’’.

关于c - 函数指针 : why is (*fptr)(6, 7) 与 (fptr)(6,7) 相同,如果函数是 add(int , int ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24508504/

相关文章:

WordPress wp_nav_menu - 将带有 <span> 的标题值添加到 <a> 中

function - 创建带有可选调用变量的函数

c - 将字符分配给在 C 中使用 malloc 声明的二维数组时收到警告

c - 将指向同类型结构成员的结构的指针分配给指向同类型结构的另一个指针

c - 为什么我的代码会立即跳转到else?

c - 我怎样才能让 program1 从 promram2 获取输入,而 program2 同时从终端获取输入?

我可以使用 xmlzipio 通过 xmlReadMemory 从内存中读取 xml 吗?

c - 包括要在 IAR 上投影的 .h 和 .c 文件

c - 为什么在库函数之前有一个序列点?

c++ - 释放后分配给指针