← 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?
- A.if (a == b)
- B.if (strcmp(a, b) == 0)
- C.if (a.equals(b))
- 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 →