Sorting a file with a lot of words.
I was thinking on making a program that would take a text file, and extract all words from it into a new file, each word on its own line, in alphabetical order, and not repeated. So if you have a file that says:
The program would output:
The quick brown fox jumped over the lazy dog.
The dog got really really mad.
The problem is that I haven't started, because in the program planning stage, I went through a lot of walls.
I think that maybe I can use fgetc to read the words char by char, words get separated by anything that is not a letter, check if the word has already been read, and then I sort the words using something like quicksort, and then I write the file.
But lets say I have a text file with hundreds of thousands of words in it. How will I store so much words? If I use linked lists, how would I sort them? The big question is... How would you do it (some pseudo code or algorithm would be useful :) )?