Question: ````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` //this is main.c #include /* Write a statement here to include the string_sort.h file */ /* Do NOT change the main function below */

`````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

//this is main.c

#include /* Write a statement here to include the string_sort.h file */ /* Do NOT change the main function below */ int main() { char * ss1[5] = {"hi", "hello", "", "how", "byebye"}; char * ss2[5] = {"hi", "hello", "", "how", "byebye"}; char * ss3[5] = {"hi", "hello", "", "how", "byebye"}; char * ss4[5] = {"hi", "hello", "", "how", "byebye"}; char * ss5[5] = {"hi", "hello", "", "how", "byebye"}; int offset, num; printf("******************** "); offset = 0; num = 5 - offset; string_sort(ss1 + offset, num); for(int i = 0; i < 5; i++) printf("%s ", ss1[i]); printf("******************** "); offset = 1; num = 5 - offset; string_sort(ss2 + offset, num); for(int i = 0; i < 5; i++) printf("%s ", ss2[i]); printf("******************** "); offset = 2; num = 5 - offset; string_sort(ss3 + offset, num); for(int i = 0; i < 5; i++) printf("%s ", ss3[i]); printf("******************** "); offset = 3; num = 5 - offset; string_sort(ss4 + offset, num); for(int i = 0; i < 5; i++) printf("%s ", ss4[i]); printf("******************** "); offset = 4; num = 5 - offset; string_sort(ss5 + offset, num); for(int i = 0; i < 5; i++) printf("%s ", ss5[i]); return 0; }

/* The output on the screen shall be the following: ******************** byebye hello hi how ******************** hi byebye hello how ******************** hi hello byebye how ******************** hi hello byebye how ******************** hi hello how byebye */

`````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

//this is string_sort.c

/*YOU CANNOT USE ANY FUNCTION FROM THE string.h Library !!! If you do, you will get zero. */ /* Write a statement here to include the string_sort.h file */ /* Input: Both s1 and s2 are strings, i.e., they are terminated by '\0'. Output: 0: if s1 and s2 are exactly the same. -1: if s1 is lexicographically smaller than s2. 1: if s1 is lexicographically larger than s2. For examples: 1) if s1 = "hello", s2 = "hallow", return 1. 2) if s1 = "hello", s2 = "hol", return -1. 3) if s1 = "", s2 = "abc", return -1. 4) if s1 = "hi", s2 = "hi", return 0. */ int my_strcmp(char * s1, char * s2){ /*WRITE YOUR CODE HERE*/ } /* Input: 'ss' is an array of strings. 'num' is the of strings in 'ss', i.e., the size of the array 'ss'. Output: The function does not return anything, but the function will sort all the elements (strings) in the array 'ss', so that all the array elements in lexicographically ascending ordering. The sorting algorithm you are going to implement is the SelectionSort that you should have learned from CSCD210. Hint: During the sorting procedure, you will use the my_strcmp function to compare elements in the array. */ void string_sort(char ** ss, int num){ /* WRITE YOUR CODE HERE */ }

`````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

//this is string_sort.h

#ifndef __STRING_SORT__ #define __STRING_SORT__ /* Write the statements here to declare all the function you develope in string_sort.c */ #endif

```````````

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 Accounting Questions!