ProgrammingHard

char *a = "cat"; char b[] = "cat"; printf("%d", strcmp(a, b) == 0); What is printed?

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

Correct answer: B. 1

Both strings hold the same characters, so strcmp returns 0 and the comparison with 0 is true. The == operator would compare addresses, which is a different test.

More C Programming questions

Exams that ask this topic