wispi
wispi

Reputation: 461

C array with "[ ]) (char **)"

I found the following declaration in the lsh source:

int (*builtin_func[]) (char **) = {
  &lsh_cd,
  &lsh_help,
  &lsh_exit
};

I'm relatively new to C, but the (*builtin_func[]) (char **) looks very odd. What does it mean?

(I'm more interested in the declaration, not the purpose of the code.)

Upvotes: 1

Views: 372

Answers (1)

alinsoar
alinsoar

Reputation: 15793

int (*builtin_func[]) (char **)

It means that the variable builtin_func is defined as

Incomplete array of pointers to functions that take pointer to pointer to char and return integers.

Next,

= { &lsh_cd, &lsh_help, &lsh_exit };

the list of initializers will complete the array , making it of 3 such pointers -- supposing that all 3 functions follow a similar signature.

Upvotes: 3

Related Questions