Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

Conduct an effective performance feedback session. page 360

Answered: 1 week ago