简体   繁体   English

这在C中意味着什么

[英]What does this mean in C

I know that int *(*func)() means a function pointer which takes no arguments and returns an integer pointer but what does the following syntax means in C: 我知道int *(*func)()表示一个函数指针,该函数指针不带任何参数并返回整数指针,但是以下语法在C中的含义是什么:

int *(*func())[]

Any explanations on how do we read such syntax in C would be very helpful. 关于如何在C语言中阅读此类语法的任何解释都将非常有帮助。

func is a function and returning a pointer to an array of pointers to int. func是一个函数,它返回一个指向int的指针数组的指针。

reference link : http://gateoverflow.in/35193/regarding-pointers 参考链接: http : //gateoverflow.in/35193/regarding-pointers

It is a function that returns an array pointer. 它是一个返回数组指针的函数。 Written more explicit, here is the meaning of the various parts: 写得更明确,这里是各个部分的含义:

item_type (*function_name(parameters))[array bounds];

Where item_type is the type of the array items in the array pointed at. 其中item_type是指向的数组中数组项的类型。

The array pointer is a pointer to an array of unknown size, which is actually allowed by C , but not overly useful. 数组指针是指向未知大小的数组的指针, 实际上C允许使用它 ,但并不太有用。

Overall, this function doesn't seem very useful and if you should ever need such an odd construct, you shouldn't write it as gibberish like this. 总体而言,该功能似乎并不是很有用,如果您需要这样一个奇怪的构造,则不应像这样乱七八糟地编写它。 Here is the equivalent form with a typedef: 这是带有typedef的等效形式:

typedef int* array_t[];

array_t* func();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM