ProgrammingVery hardProduct company OA · GATE CS

On an LP64 system (8-byte pointers), what is printed?

On an LP64 system (8-byte pointers), what is printed?
printf("%zu %zu", sizeof("abc"), sizeof("abc" + 1));
  1. A. 4 4
  2. B. 4 3
  3. C. 4 8
  4. D. 3 2

Correct answer: C. 4 8

A string literal is an array, here char[4] including the '\0', and sizeof applied directly to it gives 4. In "abc" + 1 the array first decays to char *, so the operand is a pointer and sizeof gives 8. '4 3' assumes the arithmetic just drops a character.

More C Programming questions

Exams that ask this topic