ProgrammingModerateTCS NQT · Infosys

What is sizeof "hi" in C?

  1. A. 2
  2. B. 3
  3. C. 1
  4. D. 4

Correct answer: B. 3

A string literal has type char array with room for the terminating null, so "hi" occupies 3 bytes. Its strlen is only 2.

More C Programming questions

Exams that ask this topic