"String Comparisons" Please respond to the following:

label Computer Science
account_circle Unassigned
schedule 1 Day
account_balance_wallet $5

Contrast the differences between the strcasecmp() and strcmp() function. Provide an example of each to show their usage.

Oct 20th, 2017

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 s2.

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

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Oct 20th, 2017
...
Oct 20th, 2017
Oct 20th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer