Once the input is terminated, all you need to do is iterate over the list and print out each word, one word per line. So, the output should just be the input words in alphabetic order. Simple. You should free all nodes in the list before terminating your program.
Documented, well structured, nicely formatted code is important. I suggest that you implement a number of simple, small functions to do things like read a word, create a new node, delete a node, etc. Don't forget that any data structures you define should be defined in a separate header (.h) file that is included by the implementation file(s).
extern "C" int strcmp(const char* s1, const char* s2);The strcmp function returns a integer value greater than zero if s1 is lexicographically greater than s2, zero is s1 and s2 are equal, and a value less than zero if s1 is lexicographically less than s2.
For example, the following code fragment shows you how strcmp works:
char *a, *b;
...
int x = strcmp(a, b);
if (x == 0)
cout << "a equals b\n";
else
if (x < 0)
cout << "a less than b\n";
else
cout << "a greater than b\n";
In addition to a program listing, you should turn in a trace of a few test runs of the program using various data. Try the following data sets:
1. the small red fox jumped over the tall fence 2. Hello Is Anyone Out There 3. a b c . . . z 4. z y x . . . a