1. Manipulate dynamic pointers and arrays of pointers
2. Use sorts, strings, searches and string functions.

Procedure:

1. Your new software engineering group is hired for its first paying project to develop a console application to demonstrate a possible user interface for a next generation MP3 player.
2. Your C++ program will prompt the user to input up to 20 (controlled with a global constant int) names of Artists whose songs will be loaded into the MP3 player. No artist name will be more than 80 characters (including the null terminator). Each entry needs to be loaded (strcpy would be nice) into a dynamic string created with the new keyword.
3. Each of the pointers to the strings of the Artists names needs to be stored in an array – yielding an “array of pointers”.
4. The array needs to be sorted in a separate void function such that the first alphabetical artist name should be stored in the [0] entry of the array, the next in the [1] entry etc.
5. After the array is sorted, call a void function passing the array and the number of entries in the array and print out the artists. The list should be sorted correctly.
6. After printing out the artists, prompt the user for a search string in main(). Call a void function to search through the strings pointed to by your array and return (through a call by reference) an array of references which contain the search string. The search should be case in sensitive. If you searched, for example, on “bob”, you would return references to “Bob Dylan” and “The bobs”.
7. If there were valid references returned from your search, call the same print function as in step 5 above and print out the artists that had a match in the search. If there were no valid references, cout a message to the user. You should allow for multiple searches via re prompting.
8. At the end of your program be sure to iterate through your newly allocated strings and be sure to return the allocated memory back to the operating system.

9. Here’s an example of input and output:

Enter artist name: Grateful Dead
Another artist? (y,n): y
Enter artist name: Lucinda Williams
Another artist? (y,n): y
Enter artist name: Third Eye Blind
Another artist? (y,n): y
Enter artist name: Bob Marley
Another artist? (y,n): y
Enter artist name: Metallica
Another artist? (y,n): n
Sorted Artist List:
Bob Marley
Grateful Dead
Lucinda Williams
Metallica
Third Eye Blind
Enter search string: ll
References:
Lucinda Williams
Metallica
Search Again? (y,n): y
Enter search string: a
References:
Bob Marley
Grateful Dead
Lucinda Williams
Metallica
Search Again? (y,n): y
Enter search string: x
Sorry. No references in database for search on: "x"
Search Again? (y,n): n
Press any key to continue

Recommended Answers

All 3 Replies

there is no reason for:

Enter artist name: Grateful Dead
[B]Another artist? [/B](y,n): y
Enter artist name: Lucinda Williams
[B]Another artist? [/B](y,n): y
Enter artist name: Third Eye Blind
[B]Another artist? [/B](y,n): y
etc.

If the artist is not entered, assume that is the 'no'. All you need to do is check the number of characters entered.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.