ProgrammingHardAccenture · Cognizant pattern

What is printed (64-bit LP64)?

What is printed (64-bit LP64)?
int a = 10;
void *vp = &a;
int *ip = (int *)vp;
char *cp = (char *)&a;
printf("%d %zu %zu", *ip, sizeof(vp), sizeof(*cp));
  1. A. 10 8 4
  2. B. 10 4 4
  3. C. 10 4 1
  4. D. 10 8 1

Correct answer: D. 10 8 1

sizeof(vp) is the size of a pointer itself (8 bytes on LP64), regardless of what it points to. sizeof(*cp) is sizeof(char) = 1 by definition. *ip correctly reads back the int value 10 since vp was cast through int*.

More C Programming questions

Exams that ask this topic