Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdbool.h>
- #include "dictionary.h"
- #include <stdio.h>
- #include <cs50.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdlib.h>
- int dictionary_size=1;
- FILE* dictfile;
- /**
- * Returns true if word is in dictionary else false.
- */
- bool check(const char* word){
- return true;
- }
- /**
- * Loads dictionary into memory. Returns true if successful else false.
- */
- bool load(const char* dictionary){
- dictfile = fopen(dictionary, "r");
- char symw;
- if(dictfile == NULL){
- return false;
- }
- while(feof(dictfile) == 0){
- symw = fgetc(dictfile);
- if(symw == EOF){
- break;
- }else if(symw == '\n'){
- dictionary_size++;
- }
- }
- return true;
- }
- /**
- * Returns number of words in dictionary if loaded else 0 if not yet loaded.
- */
- unsigned int size(void){
- if(dictionary_size != 0){
- return dictionary_size;
- }else{
- return 0;
- }
- }
- /**
- * Unloads dictionary from memory. Returns true if successful else false.
- */
- bool unload(void){
- if(dictfile != NULL || dictfile == NULL){
- fclose(dictfile);
- return true;
- }else return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement