Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- bool spell_check(string user)
- {
- bool flag = false;
- ifstream compare;
- string input = "dict.txt";
- string file;
- compare.open(input.c_str());
- if (!compare)
- {
- cout << "File not found\n";
- exit(0);
- }
- else
- {
- while(!(compare.eof()))
- {
- getline(compare, file);
- if (user == file)
- {
- flag = true;
- }
- }
- compare.close();
- return flag;
- }
- }
- int main()
- {
- string word;
- cout << "Enter word to spellcheck (or exit to end)\n";
- getline(cin, word);
- while (!(word == "exit"))
- {
- if (spell_check(word))
- {
- cout << word << " is spelled correctly.\n";
- }
- else
- {
- cout << word << " is not spelled correctly.\n";
- }
- cout << "Enter word to spellcheck (or exit to end)\n";
- getline(cin, word);
- }
- cout << "Ending program...\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment