ProgrammingVery hardTCS NQT · Infosys

What is printed? Assume int is 4 bytes.

What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
    int (*p)[3] = 0;
    printf("%zu", sizeof *p);
}
  1. A. 4
  2. B. 8
  3. C. 3
  4. D. 12

Correct answer: D. 12

*p has type int[3], which is 3 * 4 = 12 bytes. The null pointer is never dereferenced, because sizeof does not evaluate its operand.

More C Programming questions

Exams that ask this topic