ProgrammingEasyWipro · Capgemini pattern

Which printf format specifier is meant for printing a pointer value (an address)?

  1. A. %f
  2. B. %p
  3. C. %c
  4. D. %d

Correct answer: B. %p

%p prints a void * address in an implementation-defined form (usually hexadecimal). Printing a pointer with %d is undefined and breaks on 64-bit systems where pointers are wider than int.

More C Programming questions

Exams that ask this topic