ProgrammingHardTCS NQT · Infosys

char a[] = "hi"; char b[] = "hi"; What does a == b evaluate to?

  1. A. 1
  2. B. undefined
  3. C. 0
  4. D. depends on the compiler

Correct answer: C. 0

Distinct array objects have distinct addresses, so comparing them gives 0. Use strcmp for string equality, not ==.

More C Programming questions

Exams that ask this topic