Topical Information

This program should emphasize the use of strings in conjunction with 2D arrays.

Program Information

Allow the user to enter the names of several local businesses. Sort the business names and display the results. Continue this process until the user is out of business names.


Please use good functional decomposition to make your development easier. (Perhaps one function for sorting an array of strings, another function for swapping two strings, one for displaying an array of strings, and others to maintain the user interface. This is also a good place to use a library, btw.)

Example Run

As an example the program interaction might look something like (the parts in this color are typed by the user):

$ ./busisort.out

                 Welcome to the Business Sorting Program!!!

Please enter the name of a business:  WalMart

Your business is:

    WalMart

Another business?  y

Please enter the name of a business:  JC Penney

Your businesses are:

    JC Penney
    WalMart

Another business?  Y

Please enter the name of a business:  Merlin Muffler

Your businesses are:

    JC Penney
    Merlin Muffler
    WalMart

Another business?  yes

Please enter the name of a business:  Appleby's

Your businesses are:

    Appleby's
    JC Penney
    Merlin Muffler
    WalMart

Another business?  Yes

Please enter the name of a business:  Zippy's

Your businesses are:

    Appleby's
    JC Penney
    Merlin Muffler
    WalMart
    Zippy's

Another business?  no

Thank you for using the BSP!!

Endeavor to have an egregious day!

$

Thought Provoking Questions

  1. How do you read names that might or might not contain spaces?

  2. How do you store multiple (C)strings together in a single variable?

  3. How do you sort (C)strings? (Hint: Most books/sites discuss sorting with respect to numbers. What might you need to modify for sorting (C)strings?)

  4. How can you access a single row of a 2D array?

  5. Can you pass a single (C)string from an array to, say, strcmp?

  6. How can your 'again' question accept either characters or words? How can it be case insensitive?

This assignment is (Level 2).