Question: String Sorting in C: Using the knowlege of pointers and dynamic memory to write a C program to sort words in a single inout string.

String Sorting in C:

Using the knowlege of pointers and dynamic memory to write a C program to sort words in a single inout string. Your code will take a single, long input string that contains all words to be sorted, break them out into individual strings, sort them, and output them one per line in descending alphabetical order.

You will not know the length of the input string or its constituent strings beforehand, or how many there are, so you will not know how much memory to allocate or how many pointers you'll need to handle the input string. These are two fundamental issues you must consider.

The input string will contain a series of component strings, e.g.: thing stuff otherstuff blarp. You must extract and sort these strings. The component strings will be separated by non-alphabetic characters. You can consider any non-alphabetic character a separator, e.g.: thing1stuff3otherstuff,blarp is equivalent to the input string above. Be careful not to run off of the end of the input string as you are scanning it. Your first task should be to determine its length. You have three major segments to think about: 0. How to deal with component strings of unknown lengths 1. How to deal with an unknown number of component strings 2. How to sort an unknown number strings of an unknown length

Output Examples:

/pointersorter thing stuff otherstuff blarp

blarp

otherstuff

stuff

thing

./pointersorter thing1stuff3otherstuff,blarp

blarp

otherstuff

stuff

thing

Be careful to output your strings in descending alphabetical order Treat capital letters as greater than lower case they should come before lowercase: for words: aand, aAnd, Aand, Aand output as:

AAnd

Aand

aAnd

aand

Your program has to be efficient and fast!

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!