Both trcasecmp() and strcmp() functions compare two strings. strcmp()
compares the entire string down to the end, while strncmp()
only compares the first n characters of the strings.
It's a little funky what they return. Basically it's a difference of
the strings, so if the strings are the same, it'll return zero (since
the difference is zero). It'll return non-zero if the strings
differ; basically it will find the first mismatched character and return
less-than zero if that character in s1 is less than the
corresponding character in s2. It'll return greater-than
zero if that character in s1 is greater than that in
For the most part, people just check to see if the return value is
zero or not, because, more often than not, people are only curious if
strings are the same.
Jan 26th, 2015
Did you know? You can earn $20 for every friend you invite to Studypool!