Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Created November 6, 2018 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sojohnnysaid/c0d766be40653adc3a8c702c8afe45c5 to your computer and use it in GitHub Desktop.
Save sojohnnysaid/c0d766be40653adc3a8c702c8afe45c5 to your computer and use it in GitHub Desktop.
/**
* Loads dictionary into memory. Returns true if successful else false.
*/
bool load(const char* dictionary) // passing in the file name of the dictionary
{
// create a FILE pointer and fopen() to start the stream
FILE * dictionary_stream = fopen(dictionary, "r");
// a place to store the current word in the loop
char temp[LENGTH+1] = {'\0'};
// the condition in this while loop is also storing
// the string as well so...a slick way of doing
// two jobs in one place!
while (fscanf(dictionary_stream, "%s", temp) == 1){
dictionary_word_counter++;
}
// dictionaries/large has about 143091 words
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment