本文介绍了铸造指针float或指向函数的指针参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确切地了解这一行code的是,因为我学习C

I am trying to understand exactly what this line of code is, as I am learning C.

int (*f) (float *)

我认识的第一个部分是一个指向一个int名为女,但第二部分是什么我不确定。

I know the first part is a pointer to an int named f, however the second part is what I am unsure of.

这会被归类为指针,其强制转换为指针到浮动一个int名为f的

Would this be classed as a pointer to an int named f which is cast to a pointer-to-float

这将是一个名为f的指针,指向函数的指针参数。

Would this be a pointer named f, pointing to a function with a pointer parameter.

将是巨大的,如果有人可以帮助和可能的解释或者是两者之间的区别,因为我有一个小麻烦理解这一概念。

Would be great if someone could help and possible explain why or the difference between the two as I am having a little trouble understanding this concept.

谢谢!

推荐答案

这行声明˚F为指针的函数接受浮动* 作为它的参数和返回一个 INT

That line declares f as a pointer to a function accepting a float * as its argument and returning an int.

该声明似乎棘手,但它仅仅是跟随C的规则如果我们写了

The declaration may seem tricky, but it is just following the rules of C. If we wrote

int *f(float *);

然后,它会看起来好像˚F是返回一个函数为int * 。因此,正确的precedence必须用括号被迫围绕 *˚F

Then it would seem as though f is a function returning int *. Thus, the correct precedence must be forced using parenthesis around *f.

这篇关于铸造指针float或指向函数的指针参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:01
查看更多