0

In speller.c we call the function to load the dictionary into memory:

bool loaded = load(dictionary);

where the declaration of the function is:

bool load(const char* dictionary);

My load( ) function successfully loads the dictionary to memory but the return type is a boolean. I can't return the pointer to the place where my dictionary is loaded, so it is lost and I can't use it.

Also the check( ) function is used as:

bool misspelled = !check(word);

where the declaration is:

bool check(const char* word);

If the functions doesn't have an input to enter the location of the dictionary, how can I compare two words?

3
  • Markel, There is a solution to your quandary, but I don't want to run afoul of those academic honesty rules. ;-) Anyways, you need to think about the different ways to pass info around. You know that it can be passed into a function as a parameter and you can return a single item from a function. But you also know that the instructions for the problem set say that you can't change the parameters of the call to load() or to any of the other functions. (continued in next comment) – Cliff B Mar 27 '15 at 18:52
  • So, that means that you need to find another way to make the location of the dictionary available to the main program, and, in fact, to check() later. How else can variables be shared across all functions in a program? If only there was some way to "universally" make the location available! There has to be an answer available somewhere on this globe! ;-) (I can hear the groans from those that get it already. ;-) ) – Cliff B Mar 27 '15 at 18:53
  • week two shorts cdn.cs50.net/2012/fall/shorts/global_variables/… – wallek876 Mar 27 '15 at 19:57

You must log in to answer this question.

Browse other questions tagged .