ProgrammingVery hardProduct company OA

Read the declaration:

Read the declaration:
char *(*(*x)[4])(int);
What is `x`?
  1. A. An array of 4 pointers to functions that take an int and return a pointer to char *
  2. B. A pointer to a function that takes an int and returns an array of 4 char * values
  3. C. A pointer to an array of 4 pointers to functions that take an int and return char *
  4. D. A function that takes an int and returns a pointer to an array of 4 char * values

Correct answer: C. A pointer to an array of 4 pointers to functions that take an int and return char *

Start at the name and respect parentheses: (*x) – x is a pointer; [4] – to an array of 4; the next * – of pointers; (int) – to functions taking int; char * – returning char *. A call through it looks like (*(*x)[i])(n). Without the inner parentheses, *x[4] would make x an array first; and a function can never return an array, which rules out the third option.

More C Programming questions

Exams that ask this topic