char ** array [12][12][12]; Consider array, defined above. Which one of the following definitions and initializations of p is valid?

  1. char ** (* p) [12][12] = array;

  2. char ***** p = array;

  3. char * (* p) [12][12][12] = array;

  4. const char ** p [12][12][12] = array;


Correct Option: A
Explanation:

To solve this question, the user needs to be familiar with C/C++ syntax and the concept of pointers.

A. char ** (* p) [12][12] = array;

This option is valid. p is a pointer to a 3D array of char pointers. It is initialized to point to the first element of the array using the assignment operator =.

B. char ***** p = array;

This option is not valid. p is a pointer to a pointer to a pointer to a pointer to a pointer to a char, which is not compatible with the type of array.

C. char * (* p) [12][12][12] = array;

This option is not valid. p is a pointer to a 4D array of char pointers, which is not compatible with the type of array.

D. const char ** p [12][12][12] = array;

This option is not valid. p is a 3D array of const char pointers, which is not compatible with the type of array.

Therefore, the only valid option is:

The Answer is: A

Find more quizzes: