When coding load (using the hashtable method), I declared the structure for a node and an array of nodes within the function. However, this--of course--means I can't use these things in the check function that I'm now trying to write. I'm probably overlooking a simple solution, but where/how should I declare the struct node and node* array so that I can access them in all of the functions in dictionary.c?
A global variable is one that can be used anywhere in the program. Generally, globals are considered to be a bad practice, but there are times where they are perfectly appropriate for the situation. This is one of those cases. (There are those that say a global should NEVER be used. When you find one of those people, always evaluate their advice with an amount of suspicion. However, there should be a really, really good reason for using a global. )
To declare a global variable that can be used anywhere, it needs to be declared outside of, and before, any function or main that uses it. In this case, you could declare in either of two places - at the beginning of the dictionary.c file after the #include statements but before the first function, or in the dictionary.h file.
Note: You can declare a global outside of any function, but most operations to a global must be done inside of a function or main. Doing so outside will usually generate a compile error.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)
declaring your struct as well as your variable globally (i.e., outside of any function in
dictioanry.c) should do the job. for more information, see Variables and Scope!