function to check if word matches search word I have the following which works but was wondering if there's a better way. Better meaning more efficient and or more compact.
The function checks a trie to see if the word is in the trie.
typedef struct nodeWords
{
    char * word;
    int    index;
    struct nodeWords *left;
    struct nodeWords *right;
} nodeWords;


nodeWords ** nodeArray;

/* nodeArray is a pointer to an array of pointers. nodeArray[nodeIdx] is
   a pointer to the middle nodeWords strut where word comes from a sorted 
   list. Basic divide and conquer routine. */

bool check(const char *word)
{        
    int nodeIdx = hash(word);     
    if (nodeIdx &lt; 0)return false;       

    nodeWords * searchNode;    
    searchNode = nodeArray[nodeIdx];  //nodeArray is global    
    bool whileFlag = true, returnFlag = false;
    
    do
    {
        if (strcmp(word,searchNode-&gt;word) == 0 ) 
        {
            whileFlag = false;
            returnFlag = true;
        }
        else if (strcmp(word,searchNode-&gt;word) &lt; 0 )
        {            
            if(searchNode-&gt;left == NULL)
            {
                whileFlag = false;
            }else{
                searchNode = searchNode-&gt;left;
            }
        }else{               
            if(searchNode-&gt;right == NULL)
            {                
                whileFlag = false;
            }else{
                searchNode = searchNode-&gt;right;
            }
        }
    }while (whileFlag);     
   
    return returnFlag;
}

for instance, we could rewrite the function this way:
bool check(const char *word)
{   
    int nodeIdx = hash(word);   
    if (nodeIdx &lt; 0)return false;    

    nodeWords * searchNode; 
    searchNode = nodeArray[nodeIdx];    
    bool returnFlag = false;    

    do
    {
        if (strcmp(word,searchNode-&gt;word) == 0 )returnFlag = true;
        else if (strcmp(word,searchNode-&gt;word) &lt; 0 &amp;&amp; searchNode-&gt;left  != NULL) searchNode = searchNode-&gt;left;
        else if (strcmp(word,searchNode-&gt;word) &gt; 0 &amp;&amp; searchNode-&gt;right != NULL) searchNode = searchNode-&gt;right;
    }while (searchNode-&gt;left != NULL || searchNode-&gt;right != NULL || strcmp(word,searchNode-&gt;word) == 0);    
    
    return returnFlag;
}

I notice that the second function is actually not going to work as it's not quite the same as the first but we could change the while loop condition
I don't know C, my code is not tested.

Having whitespace at the end of lines of code is really annoying to work with.
I'm not a fan of if without curvy brackets. I have previously been bitten by adding another expression in the if and neglecting to add the brackets.
I would much prefer using break over while (whileFlag).
I would much prefer using return ... over returnFlag.
By changing the above we can change the do while loop to just a while (true) loop.
If you've followed along with the changes we can see that searchNode will be null when we want to break from the loop. And so we can remove the inner ifs by moving them to the while.

bool check(const char *word)
{
    int nodeIdx = hash(word);
    if (nodeIdx &lt; 0)
    {
        return false;
    }

    nodeWords * searchNode;
    searchNode = nodeArray[nodeIdx];

    while (searchNode != NULL)
    {
        if (strcmp(word, searchNode-&gt;word) == 0 )
        {
            return true;
        }
        else if (strcmp(word, searchNode-&gt;word) &lt; 0 )
        {
            searchNode = searchNode-&gt;left;
        }else{
            searchNode = searchNode-&gt;right;
        }
    }
    return false;
}