Question: language is in C Exercise 3.29. Implement the following specification: /* Compares stri and str2 according to dictionary (aka, * lexicographic) order, where characters are

 language is in C Exercise 3.29. Implement the following specification: /*Compares stri and str2 according to "dictionary" (aka, * "lexicographic") order, where

language is in C

Exercise 3.29. Implement the following specification: /* Compares stri and str2 according to "dictionary" (aka, * "lexicographic") order, where characters are ordered by * their ASCII values. Returns -1 if str1 comes before * str2; 0 if either stri or str 2 is NULL or if they are 5 * equal; and 1 if stri comes after str2. M */ 7 int strcmp (char * stri, char * str2); For example, consider the following unit test in strcmp_test.c: 1 #include 3 // Write strcmp here. ardwolf mardwolf"? VAST", "anos; 5 int main() { 6 printf ("aardvark, aardwolf %d ", strcmp("aardvark", "aardwolf")); printf ("AVAST, avast %d ", strcmp("AVAST", "avast")); printf ("ahoy, ahoy %d ", strcmp ("ahoy", "ahoy")); printf ("Watch for aardvarks!, " "Watches aren't for aardwolves. %d ", strcmp ("Watch for aardvarks!", "Watches aren't for aardwolves.")); 80 Chapter 3. Arrays and Strings printf ("zoology, 200 %d ", strcmp("zoology", "200")); return 0; 15 16} Once strcmp is added, compiling and running indicates the ASCII-based dic- tionary order of these strings: $ gcc -Wall - Wextra -o strcmp_test strcmp_test.c $ ./strcmp_test aardvark, aardwolf -1 AVAST, avast -1 ahoy, ahoy o Watch for aardvarks!, Watches aren't for aardwolves. -1 zoology, zoo 1 write a unit-test main program, even when it is not explicitly required

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!