ProgrammingHardTCS NQT · Infosys

char names[3][5] = {"ab", "cde", "f"}; What is strlen(names[1]) + sizeof names[2]?

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

Correct answer: B. 8

strlen(names[1]) is 3 for "cde", and sizeof names[2] is the full row length of 5 bytes. Their sum is 8. Rows of a 2D char array always have the declared width.

More C Programming questions

Exams that ask this topic