ProgrammingModerate

What is the smallest array size that holds the string "Ravi" with strcpy and no undefined behaviour?

  1. A. 4
  2. B. 6
  3. C. 5
  4. D. 8

Correct answer: C. 5

Four letters plus the terminating '\0' need five bytes. A size of four makes strcpy write one byte past the end.

More C Programming questions

Exams that ask this topic