ProgrammingHard

char s[] = "xyz"; char *p = s; p[0] = 'a'; printf("%s %zu", s, sizeof s); What is printed?

  1. A. xyz 4
  2. B. ayz 3
  3. C. axyz 4
  4. D. ayz 4

Correct answer: D. ayz 4

p points into the writable array s, not into a read-only literal, so the store is legal. sizeof s counts the terminator as well, giving 4.

More C Programming questions

Exams that ask this topic