🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: C Arrays and Strings: all 10 questions

Quiz: C Arrays and Strings · Question 3 of 10

How should you check if two C strings are equal?

How should you check if two C strings are equal?

  1. A.if (a == b)
  2. B.if (strcmp(a, b) == 0)
  3. C.if (a.equals(b))
  4. D.if (strlen(a) == strlen(b))
Answer & explanation

Correct answer: if (strcmp(a, b) == 0)

== compares addresses; strcmp compares the characters.

Can you get the rest right without peeking?

Take the timed Quiz: C Arrays and Strings quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →