Multiple choice

The strcmp function is used to __________.

  1. compare three strings

  2. compare two strings

  3. copy strings

  4. compare and then copy strings

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

strcmp is a standard C library function that compares two strings lexicographically (character by character). It returns a negative value if the first string is less than the second, zero if they're equal, and positive if the first is greater. It cannot compare three strings at once, nor does it copy strings.