Question: Write a C++ function named stringCompare that takes two C-strings s1 and s2; and returns an integer with the following rule: return 1 if s1
Write a C++ function named stringCompare that takes two C-strings s1 and s2; and returns an integer with the following rule: return 1 if s1 is greater than s2; return 0 if s1 and s2 are equal; and return -1 if s1 is less than s2. Hint: Use stringLength function given in Question #1 to find lengths. Remark:- Two C-strings are equal if they have the same length and characters at corresponding indexes are identical. A given C-string s1 is greater than another C-string s2 if the first distinguishing character of s1 is greater than that of s2 according to ascii code. Similarly for less than.
Write a main program suitable to test your function stringCompare
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
