Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in C what is the meaning of this declaration: int *(*table())[30];

Tags:

c

int *(*table())[30];

I cannot find a solution anywhere. What is the *table(), can it be a function or array?

Can you please tell me what that means?

like image 207
user1820451 Avatar asked Feb 08 '23 01:02

user1820451


1 Answers

You can decode this from the inside out:

int *(*table())[30];

The innermost binding istable(), which is a function with unspecified arguments. The next level is *table(), so table is returning a pointer to something. The next level is (*table())[30], so it's returning a pointer to a 30-length array of something. The next level is *(table())[30], so it's returning a pointer to a 30-length array of pointers to something. The final level adds the type specifier, int *(*table())[30].

So table is a function (with unspecified arguments) that returns a pointer to a 30-length array of pointers to int.

like image 119
Tom Karzes Avatar answered Feb 15 '23 02:02

Tom Karzes