Question 5
Back to Exercise
Which condition checks whether the string role equals "admin"?
- A role == "admin"
- B strcmp(role, "admin") == 0 Correct
- C strcmp(role, "admin")
- D *role == "admin"
Correct Answer: Option B
== compares addresses. strcmp() returns 0 when the strings are equal – so the bare call is true when they differ, a classic mistake.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!