1

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.)

wispi
  • 431
  • 3
  • 14

1 Answers1

3

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.

alinsoar
  • 15,386
  • 4
  • 57
  • 74