Thanks to all for the help. I took another look at the insertWord, the result must be off by 2 or more on occasion. So adding changing if to while causes the program to make the proper adjustment. and I also had to look at the previous item in the array to see if I was inserting to far back in the list. Once again using a while list to make the adjustment if the difference is more than one. This code should work for my needs. Thanks again.
Code:
void insertWord( char ***dictionary, int *count, int *capacity, char *word )
{
int wordLocation = 0;
int i = 0;
if (*count == *capacity) /* need to double my array's capacity! */
resizeDictionary(dictionary, capacity);
/* find the location of where the word should reside. For the first few words the wordLocation
* method does not seem to work, so I plan on doing the first few words manually. */
wordLocation = indexOfWord( *dictionary, *count, word );
if (wordLocation < 1 || *count == 0)
{
/* A negative word location means that the word is not in the array */
wordLocation *= -1;
/* check to see if I am off by one, if so adjust the index. */
if (*count > 0 )
{
while (wordLocation < *count && strcmp(word, (*dictionary)[wordLocation]) > 0) ++wordLocation;
while (wordLocation > 0 && strcmp(word, (*dictionary)[wordLocation-1]) < 0) --wordLocation;
}
/* printDictionary( *dictionary, *count, stdout );
printf("%d \n",wordLocation );
*/
/* The for loop is written to start at the end and move every string out one position.
* thus freeing up a spot the the please returned by indexOfWordReturn */
for (i=(*count)-1 ; i>=wordLocation ; --i )
{
(*dictionary)[i+1] = (*dictionary)[i];
}
/* copy ptr to the correct location in the dictionary array */
++*count;
(*dictionary)[wordLocation] = word;
}
}