Multiple choice

What will be the output of the following function?

main() { char *p; printf(%d %d ,sizeof(*p),sizeof(p)); }

  1. 12

  2. 22

  3. 11

  4. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The expression sizeof(*p) gives the size of a char (1 byte), while sizeof(p) gives the size of the pointer itself. In many 16-bit environments, pointers are 2 bytes, leading to the output 1 2.