Advertisement
Guest User

Untitled

a guest
Jan 6th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "spellcheck.h"
  2.  
  3. using namespace std;
  4.  
  5. bool check_spelling(char *dict, char *word)
  6. {
  7.     bool foundword = false;
  8.     string line;
  9.     ifstream dictionary (dict);
  10.     if (dictionary.is_open())
  11.     {
  12.         while (dictionary.good())
  13.             {
  14.             getline (dictionary,line);
  15.             if(string(word) == line)
  16.         {
  17.             foundword = true;
  18.             break;
  19.         }
  20.        
  21.    
  22.             }
  23.             dictionary.close();
  24.      }
  25.     else
  26.     {
  27.      throw 1;
  28.     }
  29.  
  30.     return foundword;
  31.  
  32. }
  33.  
  34. void add_word(char *dict, char *word)
  35. {
  36.     ofstream dictionary(dict);
  37.     if (dictionary.is_open())
  38.     {
  39.         dictionary << word;
  40.         dictionary << "\n";
  41.         dictionary.close();
  42.     }
  43.     else
  44.     {
  45.         throw 1;
  46.     }
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement